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
Bookmarks