Yodelayheewho
Member
Hello,
I want all sheets to be able to use the macros, but need to limit the macros to one workbook. If I open a new workbook, I don't want the macros to come with it.
One of the macros I'm using is to scroll to the next empty row. This code does NOT limit the macro to the one workbook.
So, I've tried editing the code, per below, to limit it to ThisWorkbook, but I get an error.
Thank you!
I want all sheets to be able to use the macros, but need to limit the macros to one workbook. If I open a new workbook, I don't want the macros to come with it.
One of the macros I'm using is to scroll to the next empty row. This code does NOT limit the macro to the one workbook.
Code:
Private Sub imgScrollBottom_Click()
'Lands at the next empty row
Range("D" & Rows.Count).End(xlUp).Offset(1).Select
End Sub
So, I've tried editing the code, per below, to limit it to ThisWorkbook, but I get an error.
Code:
Sub imgScrollBottom_Click()
'Lands at the next empty row
Dim wb As Workbook
Dim ws As Integer
Set wb = Workbooks("Systems Order Entry Master.xlsm")
For ws = 1 To 17 'number of worksheets
ThisWorkbook.Sheets(ws).Range("D" & Rows.Count).End(xlUp).Offset(1).Select 'Error 1004. Select method of Range class failed
Next
End Sub
Thank you!

