mysterious-dr-x
Board Regular
- Joined
- Jul 29, 2011
- Messages
- 51
If I am very lucky this will be my last question.
This code causes "Compile error: invalid or unqualified reference" & highlights ".Range" in LRs. If I take out the whole LRs section it works fine (except for the obvious fact that the 2nd mention of LR uses the same range determined above, this needs to be different) so this is clearly the problematic section.
What do I need to do to make it work?
This code causes "Compile error: invalid or unqualified reference" & highlights ".Range" in LRs. If I take out the whole LRs section it works fine (except for the obvious fact that the 2nd mention of LR uses the same range determined above, this needs to be different) so this is clearly the problematic section.
What do I need to do to make it work?
Code:
Sub UpdateGlobal()
'
' Macro5 UpdateGlobal
'
' Template: find last line, select range & copy
' Global: open, find 1st blank line, paste, save & close
' Template: clear selection
Application.DisplayAlerts = False
Dim ws As Worksheet
Dim LR As Long, lTopRow As Long, LRs As Long
Set ws = Worksheets("Drawing Register")
lTopRow = 9
With ws
LR = .Cells.Find(What:="*", After:=.Range("A1"), _
LookIn:=xlFormulas, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False).Row
Rows("9:" & LR).Select
Selection.Copy
End With
Workbooks.Open FileName:="K:\Testing\Global3.xlsm"
Sheets("Drawing Register").Select
LRs = .Cells.Find(What:="*", After:=.Range("A1"), _
LookIn:=xlFormulas, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False).Row
Range("A" & LR + 1).Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
Range("A1").Select
Application.DisplayAlerts = True
End Sub