Do Until VB Macro

J

Jerry

Greetings:

I am not sure how to get excel to perform this function. I would like
a macro to find the text value C in column C and autofill the letter C
in column A until it comes to the text value D in column C and
continue to autofill the letter D in column A. Any help would be
greatly appreciated. Thank you in advance.

Jerry
 
B

Bernie Deitrick

Jerry,

You could do something like:

Sub TryNow()
Dim myCell As Range
Dim FoundC As Boolean
Dim FoundD As Boolean

FoundC = False
FoundD = False

For Each myCell In Intersect(Range("C:C"), ActiveSheet.UsedRange)
If FoundC Or myCell.Value = "C" Then
FoundC = True
Cells(myCell.Row, 1).Value = "C"
End If
If FoundD Or myCell.Value = "D" Then
FoundC = False
FoundD = True
Cells(myCell.Row, 1).Value = "D"
End If
Next myCell
End Sub

HTH,
Bernie
MS Excel MVP
 
Top