message box detailing contents of row

Godders199

Active Member
Joined
Mar 2, 2017
Messages
313
Office Version
  1. 2013
Hello, is it possible to create a message box to do the following. assume data contained on sheet 1

Search column A, ( product) , where product matches search criteria the contents of that row are displayed in a message box, showing the column header and value in cell, for example

Product - Plugs
Stock - 1000
restock date 01/06/2018
price 50

etc

headers are on row 2

if anyone knows if this can be done, or has an example that would be a great help.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
The quickest solution is the below:

Code:
Sub message()


    Dim productRow  As Long
    Dim productName As String
    
    productName = InputBox("What product?")
    
    On Error GoTo errNotFound
    productRow = Sheets("Sheet1").Range("A:A").Find(What:=productName).row
    On Error GoTo 0
    
    MsgBox Sheets("Sheet1").Range("A2").value & " - " & Sheets("Sheet1").Range("A" & productRow).value & vbNewLine & _
           Sheets("Sheet1").Range("B2").value & " - " & Sheets("Sheet1").Range("B" & productRow).value & vbNewLine & _
           Sheets("Sheet1").Range("C2").value & " - " & Sheets("Sheet1").Range("C" & productRow).value & vbNewLine & _
           Sheets("Sheet1").Range("D2").value & " - " & Sheets("Sheet1").Range("D" & productRow).value

    Exit Sub
errNotFound:
    MsgBox "Product Name Not Found!", vbCritical


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,734
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top