So this might be a basic question, but after a decent amount of time researching the forums and internet, I can't seem to find a decent answer. I'm copying a range of cells from one workbook to another, but some columns on the Master workbook I don't need, so I'm skipping. To do this, I'm using a Do Until statement, and am doing it 3 different for each contiguous range. Cutting out most of the non-related coding, it currently looks like this --
Then I do it again, but with a different Range -
Then one more time -
If I could figure out a way to make the code -
include all the of the ranges, I wouldn't have to run this Do Until 3 different times. It goes through a large amount of data and takes a tiny bit of length to run, so if I could get it to include all of the ranges, I could drop the time it takes to run by 66%.
Hope this makes sense, if you could help it would be greatly appreciated. Thanks.
Code:
Dim Counter, CycleCounter, As Integer
Counter = 21
RowCounter = 3
'This Do Until statement makes it stop when the background color turns yellow, which in my Master sheet means it is the end of data
Do Until Master.Sheets("ZZANALYSIS_PATTERN").Cells(Counter, 1).Interior.ColorIndex = 6
'This copies the data from the Master to the new workbook
ThisWorkbook.Sheets("Sheet4").Range("A" & RowCounter, "D" & RowCounter).Value = Master.Sheets("ZZANALYSIS_PATTERN").Range("A" & Counter, "D" & Counter).Value
RowCounter = RowCounter + 1
Counter = Counter + 1
Loop
Then I do it again, but with a different Range -
Code:
Counter = 21
RowCounter = 3
'This Do Until statement makes it stop when the background color turns yellow, which in my Master sheet means it is the end of data
Do Until Master.Sheets("ZZANALYSIS_PATTERN").Cells(Counter, 1).Interior.ColorIndex = 6
'This copies the data from the Master to the new workbook
ThisWorkbook.Sheets("Sheet4").Range("E" & RowCounter, "F" & RowCounter).Value = Master.Sheets("ZZANALYSIS_PATTERN").Range("G" & Counter, "H" & Counter).Value
RowCounter = RowCounter + 1
Counter = Counter + 1
Loop
Then one more time -
Code:
Counter = 21
RowCounter = 3
'This Do Until statement makes it stop when the background color turns yellow, which in my Master sheet means it is the end of data
Do Until Master.Sheets("ZZANALYSIS_PATTERN").Cells(Counter, 1).Interior.ColorIndex = 6
'This copies the data from the Master to the new workbook
ThisWorkbook.Sheets("Sheet4").Range("G" & RowCounter, "H" & RowCounter).Value = Master.Sheets("ZZANALYSIS_PATTERN").Range("O" & Counter, "P" & Counter).Value
RowCounter = RowCounter + 1
Counter = Counter + 1
Loop
If I could figure out a way to make the code -
Code:
ThisWorkbook.Sheets("Sheet4").Range("A" & RowCounter, "D" & RowCounter).Value = Master.Sheets("ZZANALYSIS_PATTERN").Range("A" & Counter, "D" & Counter).Value
include all the of the ranges, I wouldn't have to run this Do Until 3 different times. It goes through a large amount of data and takes a tiny bit of length to run, so if I could get it to include all of the ranges, I could drop the time it takes to run by 66%.
Hope this makes sense, if you could help it would be greatly appreciated. Thanks.