Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21846

Initiating a do until loop

$
0
0
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) = ""

Viewing all articles
Browse latest Browse all 21846

Trending Articles