-3

I need to record a macro that will work on an entire row only if one of the cells in that row is answering a condition that I choose.

is there any way to record a macro that way?

thanks

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Orweisman
  • 161
  • 5
  • 10
  • 1
    No. The recorder can repeat manual steps you take like button presses, cell edits, etc. However, it is not designed to detect the logic behind these actions. Use the recorder to write the VBA for one line. Then research loops and if statements to conditionally apply the updates. @K.Fanedoul's answer includes a great demo of these techniques. – David Rushton Jun 28 '17 at 08:13

2 Answers2

2
Sub Celltest()
    For Each cel In Range("B1:B250").Cells
        If cel.value = (YOUR CONDITION) Then 
            MsgBox "CONDITION OK"
        ELSE
            MsgBox "CONDITION NOT OK"
        END IF
    Next
End Sub
K.Fanedoul
  • 281
  • 2
  • 18
0

I don't think there is a way to record that.

However you can record your macro and later edit the code (press Alt+F1) and add your condition.

Record the macro. First select the entire row you want to edit and then do your stuff as if the condition is met. After you recorded your macro edit the code and add your condition. This link may help you.

If you have an attempt to show don't hesitate. I'm glad to help

Spitzbueb
  • 5,233
  • 1
  • 20
  • 38