+ Reply to Thread
Results 1 to 5 of 5

Msg Box Macro's - Very New

  1. #1
    Registered User
    Join Date
    12-03-2017
    Location
    New Zealand
    MS-Off Ver
    EXCEL 2010
    Posts
    5

    Msg Box Macro's - Very New

    Hi there,

    I am very new to using Macros and am having a few issues. I am trying to get my excel spreadsheet to give me a pop up message box when a certain cell hits 0.00%, i was having a lot of issues when trying to group everything together so have just copied and pasted for each individual line (probably a very noob thing to do!) currently this is what i have

    [CODE]
    Private Sub Worksheet_Calculate()
    If Range("I5").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J5") & vbNewLine & Range("S5")
    End If
    If Range("I6").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J6") & vbNewLine & Range("S6")
    End If
    If Range("I7").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J7") & vbNewLine & Range("S7")
    End If
    If Range("I8").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J8") & vbNewLine & Range("S8")
    End If
    If Range("I9").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J9") & vbNewLine & Range("S9")
    End If
    If Range("I10").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J10") & vbNewLine & Range("S10")
    End If
    If Range("I11").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J11") & vbNewLine & Range("S11")
    End If
    If Range("I12").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J12") & vbNewLine & Range("S12")
    End If
    If Range("I13").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J13") & vbNewLine & Range("S13")
    End If
    If Range("I14").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J14") & vbNewLine & Range("S14")
    End If
    If Range("I15").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J15") & vbNewLine & Range("S15")
    End If
    If Range("I16").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J16") & vbNewLine & Range("S16")
    End If
    If Range("I17").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J17") & vbNewLine & Range("S17")
    End If
    If Range("I18").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J18") & vbNewLine & Range("S18")
    End If
    If Range("I19").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J19") & vbNewLine & Range("S19")
    End If
    If Range("I20").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J20") & vbNewLine & Range("S20")
    End If
    If Range("I21").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J21") & vbNewLine & Range("S21")
    End If
    If Range("I22").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J22") & vbNewLine & Range("S22")
    End If
    If Range("I23").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J23") & vbNewLine & Range("S23")
    End If
    If Range("I24").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J24") & vbNewLine & Range("S24")
    End If
    If Range("I25").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J25") & vbNewLine & Range("S25")
    End If
    If Range("I26").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J26") & vbNewLine & Range("S26")
    End If
    If Range("I27").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J27") & vbNewLine & Range("S27")
    End If
    If Range("I28").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J28") & vbNewLine & Range("S28")
    End If
    If Range("I29").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J29") & vbNewLine & Range("S29")
    End If
    If Range("I30").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J30") & vbNewLine & Range("S30")
    End If
    If Range("I31").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J31") & vbNewLine & Range("S31")
    End If
    If Range("I32").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J32") & vbNewLine & Range("S32")
    End If
    If Range("I33").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J33") & vbNewLine & Range("S33")
    End If
    If Range("I34").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J34") & vbNewLine & Range("S34")
    End If
    If Range("I35").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J35") & vbNewLine & Range("S35")
    End If
    If Range("I36").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J36") & vbNewLine & Range("S36")
    End If
    If Range("I37").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J37") & vbNewLine & Range("S37")
    End If
    If Range("I38").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J38") & vbNewLine & Range("S38")
    End If
    If Range("I39").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J39") & vbNewLine & Range("S39")
    End If
    If Range("I40").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J40") & vbNewLine & Range("S40")
    End If
    If Range("I41").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J41") & vbNewLine & Range("S41")
    End If
    If Range("I42").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J42") & vbNewLine & Range("S42")
    End If
    If Range("I43").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J43") & vbNewLine & Range("S43")
    End If
    If Range("I44").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J44") & vbNewLine & Range("S44")
    End If
    If Range("I45").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J45") & vbNewLine & Range("S45")
    End If
    If Range("I46").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J46") & vbNewLine & Range("S46")
    End If
    If Range("I47").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J47") & vbNewLine & Range("S47")
    End If
    If Range("I48").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J48") & vbNewLine & Range("S48")
    End If
    If Range("I49").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J49") & vbNewLine & Range("S49")
    End If
    If Range("I50").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J50") & vbNewLine & Range("S50")
    End If
    If Range("I51").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J51") & vbNewLine & Range("S51")
    End If
    If Range("I52").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J52") & vbNewLine & Range("S52")
    End If
    If Range("I53").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J53") & vbNewLine & Range("S53")
    End If
    If Range("I54").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J54") & vbNewLine & Range("S54")
    End If
    If Range("I55").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J55") & vbNewLine & Range("S55")
    End If
    If Range("I56").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J56") & vbNewLine & Range("S56")
    End If
    If Range("I57").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J57") & vbNewLine & Range("S57")
    End If
    If Range("I58").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J58") & vbNewLine & Range("S58")
    End If
    If Range("I59").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J59") & vbNewLine & Range("S59")
    End If
    If Range("I60").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J60") & vbNewLine & Range("S60")
    End If
    If Range("I61").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J61") & vbNewLine & Range("S61")
    End If
    If Range("I62").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J62") & vbNewLine & Range("S62")
    End If
    If Range("I63").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J63") & vbNewLine & Range("S63")
    End If
    If Range("I64").Value = "0" Then
    MsgBox "Rate limit has hit 0.00%" & vbNewLine & Range("J64") & vbNewLine & Range("S64")
    End If
    End Sub
    [CODE]

    This is clearly a very tedious way to do this and i didnt think i would have an issue with this. However for some reason this will pop up a message for some cells but does not work for all values. I think the problem is that the values in the column "I" are from a formula e.g (=H3-G3) and the cell itself only shows the percentage to 2 decimal places. However in some cells it has rounded this to 2 decimal places to make it 0.00%.

    Im obviously very new to this but was thinking if there was a way to pop up if the face value of the cell is 0.00%, rather than why i think it is not working as the actual value of some of the cells are 0.002% and getting rounded.

    Any Help Would be much appreciated thanks
    Last edited by GillonNZ; 12-04-2017 at 03:31 PM.

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Msg Box Macro's - Very New

    You need to use code tags around your code
    Ie [ CODE]code here[ /CODE] when using vba codes.

    here is something a little shorter
    Please Login or Register  to view this content.
    why do you need this running on worksheet calculate? maybe there is a more efficient way to do this, like attaching it to the actual change.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Msg Box Macro's - Very New

    GillonNZ,
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    12-03-2017
    Location
    New Zealand
    MS-Off Ver
    EXCEL 2010
    Posts
    5

    Re: Msg Box Macro's - Very New

    Thanks scottiex,

    this worked great, just needed to change the rounding number to 4 rather than 2, i imagine because column I was in percentage form. Works perfectly now, much appreciated!

  5. #5
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Msg Box Macro's - Very New

    thanks,
    and thanks for trying to fix the code tags.
    Note the final code tag should be [/CODE] you have just written [CODE] as a result it hasn't put it int he little box which you can see in my post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to add another Macro to a button to add into a larger Macro.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2016, 10:51 AM
  2. [SOLVED] Define variable in macro than calling that macro inside another macro
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2015, 10:58 AM
  3. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  4. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  5. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  6. lookup macro, solver macro, realtime macro
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2011, 06:14 PM
  7. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1