Hi guys, I have this code, the macro is in a workbook called Book3 with some data in Sheet2, I need the macro to use that data to give a certain output in another Workbook("Aro") in a sheet called "Roll"
This is the code I have, it gives me an error mesg saying subscript is out of range, how do i adjust it?
Thanks
[VBA]
Dim LR1 As Long, a As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim c As Range, firstaddress As String
Application.ScreenUpdating = False
Set ws1 = Workbooks("Aro").Sheets("Roll")
Set ws2 = Workbooks("Book3").Sheets("Sheet2")
With ws1
LR1 = .Cells(Rows.Count, 2).End(xlUp).Row
For a = 2 To LR1 Step 1
With ws2.Columns(1)
Set c = .Find(ws1.Cells(a, 2).Value, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
firstaddress = c.Address
Do
ws1.Cells(a, 2) = c.Offset(, 1)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With
Next a
End With
Application.ScreenUpdating = True
[/VBA]