+ Reply to Thread
Results 1 to 6 of 6

Display Row & column number in MsgBox

Hybrid View

  1. #1
    Registered User
    Join Date
    09-26-2009
    Location
    Mississauga, Ontario (Canada)
    MS-Off Ver
    Excel 2003
    Posts
    49

    Display Row & column number in MsgBox

    I am trying to display the row & column number in a MsgBox. Therefore, my MsgBox should display something like:

    MsgBox "Apple is in cell A1"
    Last edited by Astroboy142; 12-02-2009 at 07:28 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Display Row & column number in MsgBox

    Is the message box reporting details of the activecell? If not what cell should be reported.

    activecell
    Msgbox activecell.value & " is in cell " & activecell.address
    A1 of activesheet
    Msgbox Range("A1").value & " is in cell " & Range("A1").address
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    09-26-2009
    Location
    Mississauga, Ontario (Canada)
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Display Row & column number in MsgBox

    My macro is in Sheet2 and finds a value from Sheet1 and stores it in Result.

    Therefore,

    I want a message box stating

    MsgBox Result & " is in cell" & ______________

    here's a copy of my code:

    If WorksheetFunction.CountIf(Sheets("Schedule; Jan-Jun").Range("Data"), "S") > 0 Then
    With Sheets("Schedule; Jan-Jun").Range("Data")

    vOurResult = .Find(What:="S", After:=.Cells(1, 1), _
    LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False)
    End With

    MsgBox vOurResult & " is in Cell" &
    End If
    End Sub

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,485

    Re: Display Row & column number in MsgBox

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here


    dim rngOurResult as range
    
    set rngOurResult = .Find(What:="S", After:=.Cells(1, 1), _
    LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False)
    
    if not rngOurResult is nothing then
        MsgBox vOurResult.value & " is in cell " & vOurResult.address
    else
       Msgbox "Nothing found"
    end if
    If you make the returned variable a range object then you will have the information you need.

  5. #5
    Registered User
    Join Date
    09-26-2009
    Location
    Mississauga, Ontario (Canada)
    MS-Off Ver
    Excel 2003
    Posts
    49

    Re: Display Row & column number in MsgBox

    Thanks for the help! I had to tweak it a bit but it worked out. Sorry about not staying in compliance with the Forum rules. I'm a newbie to the whole forum deal. I will try to follow the "rules"

  6. #6
    Registered User
    Join Date
    09-26-2009
    Location
    Mississauga, Ontario (Canada)
    MS-Off Ver
    Excel 2003
    Posts
    49

    [Solved] Re: Display Row & column number in MsgBox

    Thanks for the help. I hope I added the "solve" correctly

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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