ThrottleWorks
Excel Ninja
Hi,
I am trying to define worksheet by using internal sheet name.
The reason is, the sheet names will get changed everyday so I have to use internal name.
I have defined activeworbook as ErRep, now I am trying to define sheet1 of ErRep workbook.
I tried various combinations but it is not working.
Can anyone help me in this please.
I am trying to define worksheet by using internal sheet name.
The reason is, the sheet names will get changed everyday so I have to use internal name.
I have defined activeworbook as ErRep, now I am trying to define sheet1 of ErRep workbook.
I tried various combinations but it is not working.
Can anyone help me in this please.
Code:
Dim MyRng As Range
Dim ErRep As Workbook
Set ErRep = ActiveWorkbook
'I want to define sheet1 of the ErRep in the following line
'but this line considers sheet1 of the macro workbook.
Dim Lr As Long
Lr = Sheet1.Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Row
Dim Lc As Long
Lc = Sheet1.Cells.Find("*", SearchOrder:=xlByColumns, _
LookIn:=xlValues, SearchDirection:=xlPrevious).Column
Set MyRng = Range(Cells(1, 1), Cells(Lr, Lc))