View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
Default macro for rearranging data

Sub MoveStuff()
Dim rngToSearch As Range
Dim rngPaste As Range
Dim rng As Range
Dim wksCopyFrom As Worksheet
Dim wksCopyTo As Worksheet
Dim intCounter As Integer


Set wksCopyFrom = Sheets("Sheet1")
Set wksCopyTo = Sheets("Sheet2")


With wksCopyFrom
Set rngToSearch = .Range(.Range("A2"), .Cells(Rows.Count,
"A").End(xlUp))
End With
wksCopyTo.Cells.ClearContents
Set rngPaste = wksCopyTo.Range("A2")


intCounter = 0
For Each rng In rngToSearch
If intCounter = 0 Then
rngPaste.Offset(0, intCounter).Value = rng.Value
Else
rngPaste.Offset(0, intCounter).Value = rng.Offset(0,
1).Value
End If
intCounter = intCounter + 1
If intCounter = 7 Then 'I think this is all that needs
changed. It says to copy across columns til you get to 7 then goto the
first column and the next row
intCounter = 0
Set rngPaste = rngPaste.Offset(1, 0)
End If
Next rng


End Sub

HTH

Die_Another_Day
Justin810 wrote:
I tried to apply this macro to my problem (very similar), but cant seem
to get it to repeat itself over multiple columns(I am a beginner). I
am using a data set that repeats every seven rows, and need these rows
to cover 7 columns instead. Could someone help me figure this out?


--
Justin810
------------------------------------------------------------------------
Justin810's Profile: http://www.excelforum.com/member.php...o&userid=36415
View this thread: http://www.excelforum.com/showthread...hreadid=558511