Forum Discussion
blackwelldanny
May 04, 2018Copper Contributor
Stop data at a given line and continue in another column
This is probably simple but I can't figure it out after days of looking and playing around so thank you in advance to whomever helps. I have a counter set up to fill in data up to whatever number I ...
blackwelldanny
May 04, 2018Copper Contributor
Yes sorry I wasn't clear enough. Your example is correct.
I want the data to snake over to the G column so that I can have the full report on one excel page instead of having one long column that makes me print out more than one page.
Haytham Amairah
May 04, 2018Silver Contributor
How tricky is this!
But finally, I figure it out!
This is the code:
Sub Workbook_Open()
'Written by Haytham Amairah
'Created: 5/4/2018
'Last updated: 5/4/2018
On Error GoTo handler
Dim number As Integer
number = Application.InputBox("Please enter a number:")
If number = False Then Exit Sub
Dim scell As Range
Set scell = Application.InputBox("Please select the starting cell:", , , , , , , 8)
Dim r As Integer
For counter1 = 1 To number
If scell.Offset(counter1 - 1).Row <= 55 Then
r = counter1 - 1
scell.Offset(r).Value = counter1
Else
Exit For
End If
Next counter1
r = 0
For counter2 = counter1 To number
Range("G4").Offset(r).Value = counter2
r = r + 1
Next counter2
handler:
End Sub
Please find it in the attached file.
Regards