none
Use A variable to define a Cell to enter another Variable RRS feed

  • Question

  • I would like to use my for loop to define the location to which I enter a cell value. Tried the below but getting a runt time error 13, type missmatch

    Please can someone help!!

        

    Sub Update()
    Dim LR As Long, i As Integer, t As Long, u As Long

    Sheets("Booking Info").Select
    Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    R = 1


    For i = 2 To Lastrow Step 1
    t = (i - 1) * 6
    u = t + 1


    Sheets("Booking").Select
    Cells("t", 1).Value = R
    Cells("u", 1).Value = R

    Next i

    End Sub


    Thanks

    Mike

       
    Tuesday, August 26, 2014 5:21 PM

Answers

  • By placing quotes " " around the variable names, you change them to literal text strings. You should use

    Cells(t, 1).Value = R
    Cells(u, 1).Value = R

    By the way, you need to call the line

    Sheets("Booking").Select

    only once above the For ... loop. Or don't select the sheet at all, and use

    Sheets("Booking").Cells(t, 1).Value = R
    Sheets("Booking").Cells(u, 1).Value = R


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Tuesday, August 26, 2014 7:40 PM