IREALLYambatman
Board Regular
- Joined
- Aug 31, 2016
- Messages
- 63
Hi guys,
I am trying to write a column where if I have 25 columns of data.. I want it to print every 7-8 columns, but have column B always be one of those 7-8 columns, this is what I came up with but I don't know how to add the column B to the macro.
I am trying to write a column where if I have 25 columns of data.. I want it to print every 7-8 columns, but have column B always be one of those 7-8 columns, this is what I came up with but I don't know how to add the column B to the macro.
VBA Code:
Sub PrintEvery6Columns()
Dim startCol As Integer
Dim endCol As Integer
Dim i As Integer
startCol = 2
endCol = startCol + 5
' Find the total number of columns
Dim lastCol As Long
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
' Loop through the columns, printing every 6 columns as a new page
Do While endCol <= lastCol
For i = startCol To endCol
Range(Columns(i).Address & ":" & Columns(i).Address).Select
Next i
ActiveSheet.PrintOut
startCol = endCol + 1
endCol = startCol + 5
Loop
If endCol > lastCol Then
Range(Columns(startCol).Address & ":" & Columns(lastCol).Address).Select
ActiveSheet.PrintOut
End If
End Sub