Repeating VBA macro down a range of cells...

Status
Not open for further replies.

Virge

New Member
Joined
Jun 15, 2015
Messages
8
Hi,

I have written an excel macro, see below... it works fine for one single cell, but I need it to work down a column range of say 80 to 100 cells and can"t figure out how to make it go down the column. I have tried a loop, but all I was able to do was to compare M7 with the rest of the cells. What I want is to have this macro in each cell down the column M so when that particular item inventory reaches a certain value it brings up the msg box.

Any suggestions? THANKS!!!




Public Sub myMacro()




If Range("M7").Value <= Range("N7").Value And Range("M7").Value > 0 Then


MsgBox "INVENTORY HAS REACHED ORDERING POINT of " & Range("N7").Value & " You ONLY have" & " ( " & Range("M7").Value & " ) " & "Units left.", vbCritical, "WARNING!"

ElseIf Range("M7").Value = 0 Then

MsgBox "YOU ARE OUT OF INVENTORY!!" & " " & "YOU HAVE" & " ( " & Range("M7").Value & " ) " & " - NO UNITS LEFT!", vbCritical, "ALERT!!"

Else

If Range("M7").Value < 0 Then

MsgBox "YOU HAVE NEGATIVE INVENTORY!!!" & " " & "You are NEGATIVE BY" & " " & " (- " & 0 - Range("M7").Value & " ) " & "Units", vbCritical, "ALERT!!!"

End If

End If



End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Duplicate https://www.mrexcel.com/forum/excel...g-vba-macro-down-range-cells.html#post5090420

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top