I am researching bird migration patterns and I am having trouble trying to figure out the best and easiest method of moving data around in excel. I am pretty good at excel, but I am terrible at macros and VBA coding, so I apologize in advance if my thinking of coding this looks completely wrong, and that there is nothing wrong with seeking expert advice. So far, I have used a pivot table to narrow out birds based on species count, location and dates.
After that, I moved the data from the dates per species and stack them from a range to a single column.
I did find a vba code that works (even though the output is actually moving the data sideways from left to right, it still is the same thing “moves B4:P4, B5:P5, B6:P6, etc..”), but this is only a single range at a time:
Sub main()
Dim i As Long
Dim cell As Range
For Each cell In Range("B4:P13")
Range("S4").Offset(i).Value = cell.Value
i = i + 1
Next cell
End Sub
My problem is that there are 56 species and 3 locations. So I would need to move the data 168 times, which is ridiculous. After I arrange them, I run a single factor analysis 56 times per species in each of the three locations. If anyone can help, that would be amazing and be very helpful for science.
My idea / hopes and dreams:
If I can repeat the code within the same VBA code module and change the values of the ranges and output locations for each species. All 3 locations have the same general format and location of the ranges (plus minus two extra dates), or if I can set the location to another sheet. Like so…
Sub main()
Dim i As Long
Dim cell As Range
For Each cell In Range("B4:P13")
Range("S4").Offset(i).Value = cell.Value
i = i + 1
For Each cell In Range("B15:P24")
Range("U4").Offset(i).Value = cell.Value
i = i + 1
For Each cell In Range("B26:P35")
Range("W4").Offset(i).Value = cell.Value
i = i + 1
For Each cell In Range("B37:P46")
Range("Y4").Offset(i).Value = cell.Value
i = i + 1
etc…
Next cell
End Sub
To look something like this:
Or more preferably this:
Again thank you for the help and contributions. :D