+ Reply to Thread
Results 1 to 11 of 11

Automatic Pop Up Warning Message

Hybrid View

  1. #1
    Registered User
    Join Date
    03-16-2018
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    8

    Automatic Pop Up Warning Message

    Hi guys,

    I am trying to create a set of code that transfer a daily data from cell D39 to P2 and if P2 is not empty then transfer the data to one cell below P2 (In this case its P3 and so on). However, I just want to transfer the data from cell P2 TO P8. So, when cell P8 is filled and I try to run the code, a message box will pop up. Here is my code, and the red-highlighted text is where the error is.

    Sub Copy()
         If [P2] = Empty Then
            [P2] = [D39]
        Else
            Range("P" & Rows.Count).End(xlUp).Offset(1) = [D39]
        End If
        
       If [N8] <> "" And ButtonOneClick = True Then
            MsgBox "Please Press Reset Button", vbCritical, "Error"
        End If
        
    End Sub
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Thanks in advanced!
    Attached Files Attached Files
    Last edited by 6StringJazzer; 03-20-2018 at 01:29 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Automatic Pop Up Warming Message

    What is the error?

    Where is ButtonOneClick defined in your code? Is it a variable or a control?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-16-2018
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    8

    Re: Automatic Pop Up Warming Message

    Quote Originally Posted by 6StringJazzer View Post
    What is the error?

    Where is ButtonOneClick defined in your code? Is it a variable or a control?
    The message box does not pop up.

    Dim ButtonOneClick as Boolean is my definition. Also just wondering, If I define something on vba code, am I supposed to place the definition under the Sub Copy() or above it ?


    Thanks !

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Automatic Pop Up Warming Message

    You should declare variables underneath the Sub declaration, unless there is a need to make them global (usually not).

    You are checking to see if ButtonOneClick is TRUE. Where in your code do you give it a value? If you never give it a value, it defaults to FALSE so the If condition will be FALSE and you will never see the MsgBox.

    Please show all of your code.

  5. #5
    Registered User
    Join Date
    03-16-2018
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    8

    Re: Automatic Pop Up Warming Message

    Quote Originally Posted by 6StringJazzer View Post
    You should declare variables underneath the Sub declaration, unless there is a need to make them global (usually not).

    You are checking to see if ButtonOneClick is TRUE. Where in your code do you give it a value? If you never give it a value, it defaults to FALSE so the If condition will be FALSE and you will never see the MsgBox.

    Please show all of your code.
    How do I give ButtonOneClick a value? I am new into Excel VBA so I have been learning it myself with the help of people in this forum.
    Here is all my code. Its not very complicated as its only for a simple task.


    Sub Copy()
    Dim ButtonOneClick as Boolean
         If [P2] = Empty Then
            [P2] = [D39]
        Else
            Range("P" & Rows.Count).End(xlUp).Offset(1) = [D39]
        End If
        
       If [N8] <> "" And ButtonOneClick = True Then
            MsgBox "Please Press Reset Button", vbCritical, "Error"
        End If
        
    End Sub

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Automatic Pop Up Warning Message

    I could tell you how to give ButtonOneClick a value but it won't be helpful unless I know what you want it to mean.

    You description in your first post matches your code, except for this variable, which isn't mentioned. What are you intending ButtonOneClick to be for? You are checking for it to be TRUE--what does it mean if it's TRUE?

  7. #7
    Registered User
    Join Date
    03-16-2018
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    8

    Re: Automatic Pop Up Warning Message

    Its true mean is when I click the button and cell N8 is filled, I want to show the message box automatically

  8. #8
    Registered User
    Join Date
    03-16-2018
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    8

    Re: Automatic Pop Up Warning Message

    I am just looking for a function that when a button was click with a certain condition that is true, the messagebox will pop up Or when I copy a certain data that goes beyond the limit range the messagebox will pop up.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Automatic Pop Up Warning Message

    Declaring a variable does not connect the code to the button in any way. I don't understand the relationship between the button and this code. Are you saying that you have a button, and you want this code to run when the button is clicked?

    Your latest post says something about a "limit range" but that is not mentioned earlier and I don't know what limit you mean.

    At this point I am going to ask you to attach your file so I can try to understand what you are doing. The paper clip icon does not work for attachments. Instead, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

  10. #10
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Automatic Pop Up Warning Message

    Cross posted : https://www.mrexcel.com/forum/excel-...ll-pop-up.html

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  11. #11
    Registered User
    Join Date
    03-16-2018
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    8

    Re: Automatic Pop Up Warning Message

    Thanks dominicb for telling me, I will make sure I wont do it again

+ 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] automatic warning
    By maregol in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-28-2018, 03:29 PM
  2. Warning Message
    By burgie10 in forum Excel General
    Replies: 5
    Last Post: 06-09-2015, 07:23 AM
  3. Warning message. And changing data without close message.
    By pinguino in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2013, 03:01 PM
  4. [SOLVED] How to pop up a warning message before any Excel automatic update link reminder message
    By billj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2013, 10:41 AM
  5. Automatic warning.
    By Tahz in forum Excel General
    Replies: 1
    Last Post: 10-23-2012, 05:23 PM
  6. message box warning
    By M3Cobb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2006, 06:50 PM
  7. Warning Message
    By carlito_1985 in forum Excel General
    Replies: 0
    Last Post: 04-18-2005, 11:14 PM

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