Initiating a do until loop
Hello!
I have a large set of data that I want to be extracted into certain phases. And I am trying to write a code to do so. For example the freezing cycle begins when the value in column F hits 1 and G is 18 goes until it F is 10 and G is -35 I am familiar with the do until loop which I have now and that will extract up until F is 10 and G is -15 However, is there a way to set an initial condition (F=1 and G=18)? The code below has it extracting and putting into new sheet. Thank you for your help!!
Dim mycount As Integer
mycount = 0
Dim myrow As Integer
myrow = 1
Dim oldrow As Integer
Dim startnext As Integer
Do
mycount = mycount + 1
oldrow = myrow + 1
startnext = oldrow
Sheets("Data").Select ''must be name of sheet with data
Do Until Cells(myrow, 6).Value = "10" And Cells(myrow, 7).Value = "-35"
myrow = myrow + 1
Loop
Sheets.Add
ActiveSheet.Name = "FreezeData"
Sheets("Data").Select
rows(oldrow & ":" & myrow).Select
Selection.Copy
Sheets("FreezeData").Select
Range("A1").Select
ActiveSheet.Paste
Loop Until Sheets("Data").Cells(1, myrow + 1) = ""
Re: Initiating a do until loop
Quote:
However, is there a way to set an initial condition (F=1 and G=18)?
not while you are reading the cells, you would have to use variables and assign the cell value to the variables within the loop, that way you could assign specific values to the variables prior to commencing the loop, maybe better to loop until, rather than do until, as you do with your other do loop
Re: Initiating a do until loop
Quote:
Originally Posted by
westconn1
not while you are reading the cells, you would have to use variables and assign the cell value to the variables within the loop, that way you could assign specific values to the variables prior to commencing the loop, maybe better to loop until, rather than do until, as you do with your other do loop
I don't think I understand what you mean? How would that initiate the loop? Could you give me an example?
Thank you!