+ Reply to Thread
Results 1 to 20 of 20

MsgBox to pop up if there is particular text in cell

  1. #1
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    MsgBox to pop up if there is particular text in cell

    Hi

    I have used conditional formatting, by which cells in a column (Column D) would either have "Text1" or "Text2" or "Text3". Please suggest vb code so that macro runs a check on 'Column D' and if any cell contains "Text3", a pop-up appears with message "Text3 is there"

    Thanx in advance

  2. #2
    Registered User
    Join Date
    01-23-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: MsgBox to pop up if there is particular text in cell

    Try this in the worksheet code:

    Please Login or Register  to view this content.
    Last edited by witchcraftz; 02-20-2013 at 08:38 PM.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: MsgBox to pop up if there is particular text in cell

    Hello hiteshdemla,

    pop-up appears with message "Text3 is there"
    If you want a pop-up message to appear instead of a comment added to the Cell, you could use the Code below;

    Please Login or Register  to view this content.
    Also see the "Please Consider" note at the bottom of this post.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: MsgBox to pop up if there is particular text in cell

    Hello hiteshdemla,

    Thank you for the Rep.

    I gather that you are satisfied with the solutions provided, so please, if that is the case, do mark your Thread as "Solved".

    Thank you.

  5. #5
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: MsgBox to pop up if there is particular text in cell

    Thanx witchcraftz/Winon

    I appreciate your help. I tried both the codes. none is working. I am a NOVICE. If you could please explain in a bit detail on how to do it.

    Here is what I have done:
    I opened the workbook. Went to that worksheet (Sheet 1). Pressed Alt+F11. Pasted the code in Microsoft Excel Objects>Sheet1. Than Alt+Q.

  6. #6
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: MsgBox to pop up if there is particular text in cell

    This is what I am exactly trying to do.

    I have a list of employees. A column contains the dates when they would be given confirmation letter (after 6 months of joining). The objective is whenever I open the excel and there is an employee for whom the date of issuing Conf Ltr has arrived or passed but letter is not issued, a pop-up appears and tells there are employees whose Conf Ltr needs to be issued.

    I used conditional formatting and after that, for every such employee a column "K" would show this message "Issue Confirmation Letter" highlighted in Red. I also want a pop-up. Below is a screen shot

    Untitled1.jpg
    Attached Images Attached Images

  7. #7
    Registered User
    Join Date
    01-23-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: MsgBox to pop up if there is particular text in cell

    You can use the same code but put it in

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: MsgBox to pop up if there is particular text in cell

    Hi witchcraftz

    Tried this. not working.
    m I doing it right.
    Alt+F11 > Pasting Code on Microsoft Excel Objects>Sheet1. Than Alt+Q ?

  9. #9
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: MsgBox to pop up if there is particular text in cell

    Here is a sample file.

    Really appreciate the help.
    Attached Files Attached Files

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: MsgBox to pop up if there is particular text in cell

    Hello hiteshdemla,

    Try the attached WorkBook.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Unhappy Re: MsgBox to pop up if there is particular text in cell

    Thanx Winon

    what if I replace
    Private Sub Worksheet_Change(ByVal Target As Range)
    with
    Private Sub Worksheet_Activate(ByVal Target As Range)

    I want excel code to scan each cell in column K and if it finds "Issue Confirmation Letter" in any cell it pops up the msg box.

    m sorry for being unreasonable

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: MsgBox to pop up if there is particular text in cell

    what if I replace
    Private Sub Worksheet_Change(ByVal Target As Range)
    with
    Private Sub Worksheet_Activate(ByVal Target As Range)
    That wont work!

    I want excel code to scan each cell in column K and if it finds "Issue Confirmation Letter" in any cell it pops up the msg box.
    This would require a total different approach, for which, I unfortunately do not have time for now.

    I will be out for a couple of days, and promise to check in back to see if you came right.

    In the meantime, I would suggest you forget about VBA to handle this for you, and instead use Conditional Formatting to highlight the Cells which require attention.

    Good luck!

  13. #13
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: MsgBox to pop up if there is particular text in cell

    Sure

    Thanxalot Winon.
    Will try to look for the solution. Till then conditional formatting will do

  14. #14
    Registered User
    Join Date
    01-23-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: MsgBox to pop up if there is particular text in cell

    I added some error handling to the code so that it doesn't do anything if the match doesn't find the target.

    Here is your sample worksheet back with the code added, it will run every time you open the worksheet.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    07-14-2012
    Location
    Haryana, India
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: MsgBox to pop up if there is particular text in cell

    Thanx witchcraftz
    Thanx alot

  16. #16
    Registered User
    Join Date
    01-23-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: MsgBox to pop up if there is particular text in cell

    Do itashimashte

  17. #17
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: MsgBox to pop up if there is particular text in cell

    Hello hiteshdemla,

    witchcraftz sample WorkBook does not work for me.

    I still maintain that you should use Conditional Formatting as shown in the attached WorkBook.

    Also see the "Please consider" note at the bottom of this post.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    01-23-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: MsgBox to pop up if there is particular text in cell

    My code seems to work fine for me and hiteshdemla? THe OP is already using conditional formatting to highlight the rows with delays. The request was adding a popup box too.

  19. #19
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: MsgBox to pop up if there is particular text in cell

    @ witchcraftz,

    witchcraftz's sample WorkBook does not work for me.
    What I should have said here, is that I would prefer not to use your Code without Option Explicit.
    Then having it placed in the ThisWorkBook_Open Event, will only show the Pop-Up once when the Book Opens, ignoring dynamic changes on the Sheet in question.

    If you insist on using your Code, it would be far better to do it as per the attached sample WorkBook with Calculation turned on Automatic.

    Also see this link why it is important to use Option Explicit.
    http://eileenslounge.com/viewtopic.php?f=30&t=2281

    Hope it helps.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    01-23-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: MsgBox to pop up if there is particular text in cell

    Using undefined variables can be a problem. However in this situation there are only 5 lines of code, so I went the easy route and left it as is, pretty sure there won't be much (if any) more VBA code added that could cause any issues.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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