Results 1 to 16 of 16

Return Specific values in msgbox avoiding blank cells

Threaded View

  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.



    Sub test2()
    Dim a As String
    Dim b As String
    Dim c As String
    Dim d As String
    Dim e As String
    Dim f As String
    Dim g As String
    Dim h As String
    
    If Selection.Cells(2, 5) = "" Then
    a = ""
    Else
    a = "8mm - " & Selection.Cells(2, 5) & " M.T., "
    
    End If
    
    If Selection.Cells(2, 6) = "" Then
    b = ""
    Else
    b = "10mm - " & Selection.Cells(2, 6) & " M.T., "
    End If
    
    If Selection.Cells(2, 7) = "" Then
    c = ""
    Else
    c = "12mm - " & Selection.Cells(2, 7) & " M.T., "
    
    End If
    
    If Selection.Cells(2, 8) = "" Then
    d = ""
    Else
    d = "16mm - " & Selection.Cells(2, 8) & " M.T., "
    
    End If
    
    If Selection.Cells(2, 9) = "" Then
    e = ""
    Else
    e = "20mm - " & Selection.Cells(2, 9) & " M.T., "
    
    End If
    
    If Selection.Cells(2, 10) = "" Then
    f = ""
    Else
    f = "25mm - " & Selection.Cells(2, 10) & " M.T., "
    
    End If
    
    If Selection.Cells(2, 11) = "" Then
    g = ""
    Else
    g = "28mm - " & Selection.Cells(2, 11) & " M.T., "
    
    End If
    
    If Selection.Cells(2, 12) = "" Then
    h = ""
    Else
    h = "32mm - " & Selection.Cells(2, 12) & " M.T., "
    
    End If
    
    MsgBox a & b & c & d & e & f & g & h
    
    End Sub
    Attached Files Attached Files
    Last edited by yashagarwal; 05-20-2016 at 11:41 PM. Reason: Attached excel file

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. 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