Kdevisser25
New Member
- Joined
- Sep 13, 2021
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
I have a base sheet where I have notes to a user and instructions that contain macros. I would like to user to import a sheet that is downloaded off a database into the workbook as Sheet2 and then go back to the "Base Sheet" (where the macro buttons are located) and select the buttons to appropriately scale and format the data. I am no VSB whiz and I am having trouble getting the macro on the base sheet to run on Sheet2 vice the Base sheet.
Below is the code I am trying to run which works well on the current sheet, but not on a different sheet in the workbook. Even when I try to call out Sheet2 instead of ActiveSheet I still can't get it to work right.
Sub InsertPageBreaks()
'updateby Extendoffice
Dim I As Long, J As Long
J = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For I = J To 3 Step -1
If Range("A" & I).Value <> Range("A" & I - 1).Value Then
ActiveSheet.HPageBreaks.Add Before:=Range("A" & I)
End If
Next I
End Sub
Any thoughts? Any help would be greatly appreciated.
Below is the code I am trying to run which works well on the current sheet, but not on a different sheet in the workbook. Even when I try to call out Sheet2 instead of ActiveSheet I still can't get it to work right.
Sub InsertPageBreaks()
'updateby Extendoffice
Dim I As Long, J As Long
J = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For I = J To 3 Step -1
If Range("A" & I).Value <> Range("A" & I - 1).Value Then
ActiveSheet.HPageBreaks.Add Before:=Range("A" & I)
End If
Next I
End Sub
Any thoughts? Any help would be greatly appreciated.