vendredi 17 avril 2020

Excel - VBA macro and if

I'm new in VBA and I am trying to do simply macro. I need my macro to work like this:

1) If there is a value in E5 cell, which is greater than 1, show a message box with text like "Your value is" /get value from E5/

2) I want to repeat this condition for all cells in column E.

First, I started with something that would work:

Sub test()
If Range("E5").Value > "1" Then
MsgBox "Your value is" (here I don't know how to import real value from E5)
End If
End Sub

And then I can click "Run" and the macro works ok (it means "formally ok", because this is not the target effect yet). But this macro only works when I click "Run" and I would like it to work always, even when I turn Excel off and turn it on again. Assigning a macro to an auto-shape is much easier, but here I fell :(

Aucun commentaire:

Enregistrer un commentaire