Key points,
- I am currently importing tabular data from anywhere between 5 and 7 worksheets.
- I am grabbing the data from each and pasting (end(x1up)) to a single dump worksheet.
- I am then using a Do While Loop to analyze for instances of two strings (using inStr - the beginning and end of a selected range).
- Once this range is selected, I am stair-stepping down and to the right for my paste by a factor of 17 columns and 100 rows.
Here's the code:
Sub MoveStairStep()
Dim iterator As Integer
Dim columnsToTheRight As Integer
Dim rowsDown As Integer
Dim rowStartCutOffset As Integer
Dim rowEndCutOffset As Integer
Dim sheet As Worksheet
Dim rStart As Range
iterator = 0
columnsToTheRight = 12 + 5
rowsDown = 0
Do While iterator < 1000
'Set range variable
Set rStart = Range("E66")
'Find string Statistics in title to begin loop
If InStr(rStart.Offset(iterator, 0).Value, "Statistics") Then
rowStartCutOffset = iterator
End If
'loop until finding string Finish
If InStr(rStart.Offset(iterator, 0).Value, "Finish") Then
rowEndCutOffset = iterator
rStart.Offset(rowStartCutOffset, 0).Resize(rowEndCutOffset - rowStartCutOffset + 1, 12).Select
Selection.Cut
' THIS IS THE PART I NEED REVISED
rStart.Select
rStart.Offset(rowsDown, columnsToTheRight).Select
ThisWorkbook.Sheets("Data").Paste
Application.CutCopyMode = False
columnsToTheRight = columnsToTheRight + 12 + 5
rowsDown = rowsDown + 150
End If
iterator = iterator + 1
Loop
End Sub
**Request**
I have since named 6 ranges that I would like to loop through to tell excel where I want each subsequent range pasted after analysis and selection.cut. The ultimate goal is to have the data pasted to the same place everytime regardless of the dynamic nature of the imported data. The ranges are A_1, B_1, C_1, A_2, B_2, and C_2.
THANK YOU!
Bookmarks