HELP w/ Macro and IF Statement

R

randy_tn

I am needing to have a macro look at a Cell (B8) and determine if it ha
a value greater than 0. IF it does I need it to copy the contents t
another cell (M8) then move down 4 cells and repete IF the value i
"======" then I am done.

Can somone PLEASE help me with this
 
P

Phil Webb

Something like this should be close to what you're looking for. You didn't
state whether or not the copied values will be copied into column M in the
same row as the original value in column B, but I made that assumption.
The loop below will terminate if either the cell value contains the string
"======" (6 equal signs bounded by double quotes) or the cell is empty.

Regards,
Phil Webb

Sub CopyPositiveVals()
Dim cel As Range

Set cel = Range("B8")
Do
If cel.Value > 0 Then
Cells(cel.Row, 13).Value = cel.Value
End If
Set cel = cel.Offset(4, 0)
Loop Until cel.Value = Chr(34) & "======" & Chr(34) Or IsEmpty(cel)End
Sub
 

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

Top