HI,
I'm using Access 2000.
I have 13 columns of data and about 400 rows.
We have a big plotter where all the data can fit on one large sheet of paper, but only if the data is divided into 2 separate sets of columns.
So i need my data divided into: A1 thru M200 and then O2 thru AA200.
In other words, any data below row 200 should be moved and placed in columns O thru AA.
I found some code that works for data in one column (A) only. i'm trying to tweak it to work with more than one column, but since i don't understand the code, it hasn't been successful yet.
The webpage where i found it is:
"Here's a handy little bit of code if you have a long list of data in 1 Column ("A" in this case). It will automatically move the range of data at each horizontal page break to adjacent columns."
Sub RowsToColumns()
Dim rCol As Range
Dim rCell1 As Range, rCell2 As Range
Dim i As Integer, iPBcount As Integer
Dim Sht As Worksheet
Application.StatusBar = "Converting, please wait....!"
Application.ScreenUpdating = False
'Set range variable to Selection
Set Sht = ActiveSheet
Set rCol = Sht.UsedRange.Columns(1)
'Insert page breaks
Sht.PageSetup.PrintArea = ""
Sht.PageSetup.Zoom = 100
ActiveWindow.View = xlPageBreakPreview
'Count only horizontal page breaks and pass to an Integer
iPBcount = Sht.HPageBreaks.Count
On Error Resume Next
'Loop as many times as there horizontal page breaks.
For i = 1 To iPBcount
'Set variable 1 to page break X
Set rCell1 = Sht.HPageBreaks(i).Location
'Set variable 2 to X page break
Set rCell2 = Sht.HPageBreaks(i + 1).Location.Offset(-1, 0)
If rCell2 Is Nothing Then 'Last page break
Range(rCell1, rCol.Cells(65536, 1).End(xlUp)).Cut _
Destination:=Sht.Cells(1, i + 1)
Else
Range(rCell1, rCell2).Cut Destination:=Sht.Cells(1, i + 1)
End If
Set rCell1 = Nothing
Set rCell2 = Nothing
Next i
On Error GoTo 0
ActiveWindow.View = xlNormalView
Application.ScreenUpdating = True
Sht.DisplayPageBreaks = False
Application.Goto rCol.Cells(1, 1), True
Set rCol = Nothing
Application.StatusBar = ""
End Sub
I'm using Access 2000.
I have 13 columns of data and about 400 rows.
We have a big plotter where all the data can fit on one large sheet of paper, but only if the data is divided into 2 separate sets of columns.
So i need my data divided into: A1 thru M200 and then O2 thru AA200.
In other words, any data below row 200 should be moved and placed in columns O thru AA.
I found some code that works for data in one column (A) only. i'm trying to tweak it to work with more than one column, but since i don't understand the code, it hasn't been successful yet.
The webpage where i found it is:
"Here's a handy little bit of code if you have a long list of data in 1 Column ("A" in this case). It will automatically move the range of data at each horizontal page break to adjacent columns."
Sub RowsToColumns()
Dim rCol As Range
Dim rCell1 As Range, rCell2 As Range
Dim i As Integer, iPBcount As Integer
Dim Sht As Worksheet
Application.StatusBar = "Converting, please wait....!"
Application.ScreenUpdating = False
'Set range variable to Selection
Set Sht = ActiveSheet
Set rCol = Sht.UsedRange.Columns(1)
'Insert page breaks
Sht.PageSetup.PrintArea = ""
Sht.PageSetup.Zoom = 100
ActiveWindow.View = xlPageBreakPreview
'Count only horizontal page breaks and pass to an Integer
iPBcount = Sht.HPageBreaks.Count
On Error Resume Next
'Loop as many times as there horizontal page breaks.
For i = 1 To iPBcount
'Set variable 1 to page break X
Set rCell1 = Sht.HPageBreaks(i).Location
'Set variable 2 to X page break
Set rCell2 = Sht.HPageBreaks(i + 1).Location.Offset(-1, 0)
If rCell2 Is Nothing Then 'Last page break
Range(rCell1, rCol.Cells(65536, 1).End(xlUp)).Cut _
Destination:=Sht.Cells(1, i + 1)
Else
Range(rCell1, rCell2).Cut Destination:=Sht.Cells(1, i + 1)
End If
Set rCell1 = Nothing
Set rCell2 = Nothing
Next i
On Error GoTo 0
ActiveWindow.View = xlNormalView
Application.ScreenUpdating = True
Sht.DisplayPageBreaks = False
Application.Goto rCol.Cells(1, 1), True
Set rCol = Nothing
Application.StatusBar = ""
End Sub