
November 3rd, 2004, 04:41 PM
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Increment problem
Hi...I've got a very large worksheet (10,000 rows) in a spreadsheet that I need to make smaller (obviously). A pull from our system at work created this Excel spreadsheet and instead of being 2000 rows, it was 10,000. It included a field that isn't needed which is why it over bloated itself. Anyways, I need to transpose the values from one column, over four columns. I have no problem getting my macro to do it to one specific range of cells, but I'm unsure of how to go about getting it to do it for the entire worksheet. I have included my code below. I started to do it manually, as my code will indicate, but wanted a better and faster way of doing this.
Code:
Sub MyTranspose()
'------------------ BEGIN - USER MODIFIABLE SECTION ------------------
r_first = 163 ' the row BEFORE the first row of your list
r_last = 9958 ' the last row of your list
r_step = 4 ' the number of rows between the row borders
'------------------ END - USER MODIFIABLE SECTION --------------------
Dim a As Range
Set a = Selection ' remember cell selection
Cells.Select
For r = r_first To r_last Step r_step
Range("E164:E167").Select
Selection.Copy
Range("F9").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
Next r
If (r_last - r_first) Mod r_step <> 0 Then
r = r_last
Range("E164:E167").Select
Selection.Copy
Range("F9").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
End If
End Sub
|