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

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

    Next i

    End Sub



    Tuesday, August 26, 2014 5:21 PM


  • 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


    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 (

    Tuesday, August 26, 2014 7:40 PM