+ Reply to Thread
Results 1 to 16 of 16

Return Specific values in msgbox avoiding blank cells

  1. #1
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Exclamation Return Specific values in msgbox avoiding blank cells

    Im trying to return specific values in a message box using Excel VBA. Please have a look at my data in the attached file.
    This data is first selected, then the macro is run.
    The macro should return a Msgbox containing values in this order:
    8mm- 13.05,9.34,0.08, 10mm-3.19,6.005, 12mm-2.53,6.67, 16mm-17.34, 20mm-0.97, 25mm-8.

    Ive written a code by myself, which only return the values present in the first row.
    Kindly help me out here.



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by yashagarwal; 05-20-2016 at 11:41 PM. Reason: Attached excel file

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Return Specific values in msgbox avoiding blank cells

    Please attach file instead of image.

  3. #3
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Return Specific values in msgbox avoiding blank cells

    Quote Originally Posted by bakerman2 View Post
    Please attach file instead of image.
    Ive attached the excel sheet as well :D

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Return Specific values in msgbox avoiding blank cells

    Heres one way

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Return Specific values in msgbox avoiding blank cells

    Try this
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Return Specific values in msgbox avoiding blank cells

    Quote Originally Posted by jindon View Post
    Try this
    Please Login or Register  to view this content.
    Works perfectly,
    Can we define the entire result that comes in the MSGBOX as one Value say "A"
    so that if i say MSGBOX A, i will get the result?

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Return Specific values in msgbox avoiding blank cells

    Sorry, but I don't understand what you are asking.

  8. #8
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Return Specific values in msgbox avoiding blank cells

    Quote Originally Posted by jindon View Post
    Sorry, but I don't understand what you are asking.
    I mean to say that "IIf(Len(msg), Mid$(msg, 3), "No data")" can be represented as one letter. Like Setting "IIf(Len(msg), Mid$(msg, 3), "No data")"=A. And i can see the result in the msgbox by entering the code MSGBOX A

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Return Specific values in msgbox avoiding blank cells

    Quote Originally Posted by yashagarwal View Post
    And i can see the result in the msgbox by entering the code MSGBOX A
    Where are you entering to?

  10. #10
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Return Specific values in msgbox avoiding blank cells

    Quote Originally Posted by jindon View Post
    Where are you entering to?
    Ive a code by which im sending the result as an email. Need the text to come in the emails body.
    I figured it out.

    The thing is that, the code is static to only this data. Since this was a sample data its working. In my original workbook the same table maybe located elsewhere. The original workbook has 100s of such tables. My aim is to select the specific table i want with the mouse pointer and then run the macro on that table to extract these specific values. How can we make this code dynamic to run on any selected table/range?

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Return Specific values in msgbox avoiding blank cells

    You mean something like this?
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Return Specific values in msgbox avoiding blank cells

    Quote Originally Posted by jindon View Post
    You mean something like this?
    Please Login or Register  to view this content.
    yes, something like this.

    But how can we make this code dynamic, In my original workbook the same table maybe located elsewhere. The original workbook has 100s of such tables. My aim is to select the specific table i want with the mouse pointer and then run the macro on that table to extract these specific values. How can we make this code dynamic to run on any selected table/range?

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Return Specific values in msgbox avoiding blank cells

    Then just change to
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    03-16-2014
    Location
    Bangalore
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Return Specific values in msgbox avoiding blank cells

    Quote Originally Posted by jindon View Post
    Then just change to
    Please Login or Register  to view this content.
    please see the image attached below:
    Untitled.jpg

    when the code is run on my original sheet, it gives this as result. But when i copy the same data to a new workbook and run the code there, it give the proper result. How?

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Return Specific values in msgbox avoiding blank cells

    Can not replicate the issue.

    Upload your workbook.

    And you should not full quote of my post unless it is really needed.
    The forum doesn't ike it.

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Return Specific values in msgbox avoiding blank cells

    You probably have same header just below the data area.
    change to
    Please Login or Register  to view this content.

+ 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. Replies: 4
    Last Post: 10-01-2015, 11:01 AM
  2. [SOLVED] find non-blank cells and return line with only specific text
    By greg19 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-30-2014, 01:43 AM
  3. Return specific values from one workbook to another, in specific cells
    By Bobbie12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2013, 03:33 PM
  4. Adding cells with values but if cells do not have values then return blank
    By jonnykhan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-13-2012, 12:07 PM
  5. [SOLVED] Removing duplications and avoiding blank cells
    By mvg688 in forum Excel General
    Replies: 1
    Last Post: 05-18-2012, 09:57 AM
  6. Avoiding #VALUE errors on blank cells
    By fdservices in forum Excel General
    Replies: 10
    Last Post: 06-27-2008, 12:15 PM
  7. [SOLVED] Return Address of Blank Cells in MsgBox
    By Sandy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-25-2005, 10:05 AM

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