Do Until VB Macro

  • Thread starter Thread starter Jerry
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top