andycapp28
Technical User
I have used the range coding before in a single Workbook.
I require to search Column J in Workbook/Worksheet named TY_Multi_Gifts.xls/TY_Multi_Gifts
Using the range for a single worksheet works fine in other macros, I just can't grasp how to make it work using Workbook and Worksheet names.
I get "invalid or unqualified reference" on the set rLookfor, area highlighted is the .[J1) when compiling.
If I comment it out to check for other compilation errors I get "subscript out of range" on the With Worksheets("TY_Certificate_Fund_Description"). I clearly misunderstand the use of the With.
I hope the solutions are'nt too obvious to be bothering everyone but its so frustrating and taking me too long to resolve.
I require to search Column J in Workbook/Worksheet named TY_Multi_Gifts.xls/TY_Multi_Gifts
Using the range for a single worksheet works fine in other macros, I just can't grasp how to make it work using Workbook and Worksheet names.
I get "invalid or unqualified reference" on the set rLookfor, area highlighted is the .[J1) when compiling.
If I comment it out to check for other compilation errors I get "subscript out of range" on the With Worksheets("TY_Certificate_Fund_Description"). I clearly misunderstand the use of the With.
I hope the solutions are'nt too obvious to be bothering everyone but its so frustrating and taking me too long to resolve.
Code:
Sub Get_TY_Certs_Desc()
Dim r As Range
Dim rLookfor As Range
Dim rLookin As Range
Dim curWB As Workbook, destWB As Workbook
'With Application
'.EnableEvents = False
'.ScreenUpdating = False
'End With
Set curWB = ActiveWorkbook
' Open File
Set destWB = Workbooks.Open("P:\TY_Certificates\TY_Multi_Gifts.xls")
Set destWS = Worksheets("TY_Multi_Gifts")
Set rLookfor = destWS.Range(.[J1], .[J1].End(xlDown))
With Worksheets("TY_Certificate_Fund_Description")
Set rLookin = .Range(.[A1], .[A1].End(xlDown))
End With
For Each c In rLookfor
Set r = rLookin.Find(a.Value)
If Not r Is Nothing Then
r.Offset(0, 2).Copy
c.Offset(0, 2).PasteSpecial xlPasteAll
End If
Next
'With Application
'.EnableEvents = True
'.ScreenUpdating = True
'End With
End Sub