View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Adding a condition a Macro

Your scenario description is a little vague but here
are the basics. Assumes header in Row 1.

Dim lstCol As Long, c As Range
lstCol = Cells(1, Columns.Count).End(xlToLeft).Column

For Each c In Range("A1", Cells(1, lstCol))
If Left(ActiveCell.Value, 3) = Left(c.Value, 3) Then
"Paste something somewhere
Else
ActiveCell = "Nothing" 'not sure about this
End If
Next

This code is not intended to work. It is intended for
guidance only.




"Lucson" wrote:

I have a working Macro where I want to add a condition to compare the 1st 3
digit of a cell to the 1st 3 digit of a header column, if matches, paste
under that column if not check next Header column. If the intersection has
nothing put "NOTHING".

Note: I am not a professional programmer. I learn (and still) to code VBA to
make my life easier, when an action is programmable.
--
Always Learning