esseispercipi4
New Member
- Joined
- Apr 9, 2012
- Messages
- 22
Sorry if this issue has already been addressed elsewhere; I couldn't find a thread anywhere.
I'm using VBA to set Print Titles to the row that the currently-selected cell is in. However, it keeps entering the wrong row into Print Titles (however, the MsgBox lines return the correct row number).
The other variable is used elsewhere in my code, but I've commented all of those lines out to see if I was somehow changing the variable, so now these are the only active lines of code.
If the user is in row 1, then the Print Titles is set at 2:2. If the user is in row 2, then the Print Titles is set at 3:3. If the user is in row 4, then the Print Titles is set at 7:7. If the user is in row 7, then the Print Titles is set at 13:13 (this is the same in every file I've run the macro in).
I'm at a loss as to how the MsgBox displays the correct value each time, but the Print Titles contains a different value.
Any help would be greatly appreciated. Thanks
I'm using VBA to set Print Titles to the row that the currently-selected cell is in. However, it keeps entering the wrong row into Print Titles (however, the MsgBox lines return the correct row number).
Code:
[INDENT=2][I]Sub Border_PrintArea()
[/I][/INDENT]
[INDENT=2][I]Dim activePrintRow As Integer[/I][/INDENT]
[INDENT=2][I]Dim activePrintColumn As Integer[/I][/INDENT]
[INDENT=2][I]activePrintRow = ActiveCell.Row[/I][/INDENT]
[INDENT=2][I]activePrintColumn = ActiveCell.Column[/I][/INDENT]
[INDENT=2][I]MsgBox activePrintRow
[/I][/INDENT]
[INDENT=2][I] With ActiveSheet.PageSetup[/I][/INDENT]
[INDENT=2][I]
MsgBox activePrintRow[/I][/INDENT]
[INDENT=2][I] .PrintTitleRows = activePrintRow & ":" & activePrintRow[/I][/INDENT]
[INDENT=2][I] End With[/I][/INDENT]
[INDENT=2][I]
MsgBox activePrintRow
[/I][/INDENT]
[INDENT=2][I]End Sub[/I][/INDENT]
The other variable is used elsewhere in my code, but I've commented all of those lines out to see if I was somehow changing the variable, so now these are the only active lines of code.
If the user is in row 1, then the Print Titles is set at 2:2. If the user is in row 2, then the Print Titles is set at 3:3. If the user is in row 4, then the Print Titles is set at 7:7. If the user is in row 7, then the Print Titles is set at 13:13 (this is the same in every file I've run the macro in).
I'm at a loss as to how the MsgBox displays the correct value each time, but the Print Titles contains a different value.
Any help would be greatly appreciated. Thanks