I have data that I import into a Workbook. It doesn't have all the information I need so will be combining it with other data from another workbook (Not ideal, but I'm not in control of the other workbooks).
I don't want to amend the import data, so I want to run a macro to look at each cell in the range in one worksheet, and then put an answer in the corresponding cell in another worksheet. I've tried various different ways, but can't quite get it to work. The most recent attempt is using R1C1 reference style, but I'm getting a Method 'Range' of object'_Worksheet' failed error the first time it hits the IF statement.
Is the code way off base, or does it just need tinkered with? Any suggestions would be appreciated.
The range is D6:JC106
I don't want to amend the import data, so I want to run a macro to look at each cell in the range in one worksheet, and then put an answer in the corresponding cell in another worksheet. I've tried various different ways, but can't quite get it to work. The most recent attempt is using R1C1 reference style, but I'm getting a Method 'Range' of object'_Worksheet' failed error the first time it hits the IF statement.
Is the code way off base, or does it just need tinkered with? Any suggestions would be appreciated.
The range is D6:JC106
VBA Code:
Sub MergeRotas()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets("CDemandsData")
Dim ws2 As Worksheet
Set ws2 = ThisWorkbook.Sheets("Work Rota")
Dim r As Integer
Dim c As Integer
For c = 4 To 263
For r = 6 To 106
If ws1.Range(c, r).Value = "Holiday" Then
ws2.Range(c, r).Value = "Leave"
End If
Next r
Next c
End Sub