- Code: Select all
If RPdatacopied = False Then
Sheets("Win").Range("BS5:BT40").Value = ""
endR = Sheets("RPData").Range("A1").Value
r2 = 5
For r = 3 To endR
If Sheets("RPData").Cells(r, 7).Value = 1 Then
Sheets("Win").Cells(r2, 71).Value = Sheets("RPData").Cells(r, 3).Value
Sheets("Win").Cells(r2, 72).Value = Sheets("RPData").Cells(r, 6).Value
End If
r2 = r2 + 1
Next r
RPdatacopied = True
End If
Basically, data is meant to be copied from sheet "RPData" to sheet "Win" starting from row 5, anytime I change markets (i.e. the variable 'RPdatacopied' becomes False. Data is being copied alright, but for some reason it is not starting from row 5 in sheet "Win", and just keeps starting from different rows randomly - sometimes row 30, sometimes row 57 and so on. So, the problem would seem to be with the variable r2, but I can't understand as I thought I have made it to start from row 5 by r2 = 5. Help please!
Thanks
Dan