View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vasant Nanavati Vasant Nanavati is offline
external usenet poster
 
Posts: 1,080
Default Need help with recorded macro

(Untested)

(Haven't checked your code; assuming it works)

Dim i As Integer
For i = 1 To 261
Range("B4:F4").Offset(i - 1, 0).Select NEED TO MOVE TO NEXT ROW AFTER THE
MACRO
COMPLETES
Selection.Copy
Range("G3").Select THIS CAN REMAIN STATIC
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, transpose:=True
Application.CutCopyMode = False
Selection.Sort Key1:=Range("G3"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.Copy
Range("B4").Offset(i - 1, 0).Select this needs to adjust to the next
cell down as the
macro completes a cycle
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, transpose:=True
Next i
End Sub

I'd advise getting away from all the selecting, though.
__________________________________________________ _________________________


"JHL" wrote in message
...
Hello,
My project involves copying a row of 5 numbers, transpose to another
column,
sort the column, then transpose back to the original location, then move
to
the next row an repeat.

I have the following macro I created using the macro recorder. I'm not
VBA
savvy. The macro does the job I need, however, I have 261 rows in my
sheet
that I need this to perform. I do not know how to get the macro to move
to
the row, perform the steps and move to the next and so on.

Will someone please show me how to adjust my code to finish my project?
Thanks in advance.

Sub transpose()
'
' transpose Macro
' Copy, transpose, sort, transpose multiple rows
'

'
Range("B4:F4").Select NEED TO MOVE TO NEXT ROW AFTER THE MACRO
COMPLETES
Selection.Copy
Range("G3").Select THIS CAN REMAIN STATIC
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, transpose:=True
Application.CutCopyMode = False
Selection.Sort Key1:=Range("G3"), Order1:=xlAscending, Header:=xlGuess,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.Copy
Range("B4").Select this needs to adjust to the next cell down as the
macro completes a cycle
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone,
SkipBlanks:=False _
, transpose:=True
End Sub