VBA - Posting Multiple Table Results in MsgBox Using an InputBox to Search [VLookup?]

Wildernapalm

New Member
Joined
Jun 23, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hey everybody! I've been scouring these boards all week and have seen a pretty kind community.
I'll be frank, I'm applying for a job and I have an assessment they want me to complete to the best of my abilities. It was expressly stated I could use whatever resources I could get my hands on and I feel like now's the time!

What I've Roughly been asked to do is create a button on a sheet, the button will open an InputBox that can be used to search against a table on a separate sheet and do a very specific VLookup that results in a MsgBox displaying said VLookup results of multiple non-sequential columns.
I'd share the exact wording but I feel it might out the company and its hiring practices and that seems unprofessional.


VBA Code:
Sub InputBox()

    Dim b As String
    Dim c As String
    Dim e As String
    Dim h As Currency
    Dim j As Long
    Dim m As Currency
    Dim n As Currency
    Dim o As Currency
    Dim i As Integer
    Dim lngLastRow As Range
    
    Set lngLastRow = Worksheets("2. Formatting").Range("B7:R17")
    
    c = Application.InputBox("Select An Engagement")
    
    For i = 8 To 17

        If Cells(i, 1).Value Like "*c*" Then
            e = Cells(i, 2).Value
            h = Cells(i, 6).Value
            j = Cells(i, 7).Value
            m = Cells(i, 10).Value
            n = Cells(i, 11).Value
            o = Cells(i, 12).Value
            b = Cells(i, -1).Value
        End If
    Next i


    MsgBox " Engagement Name: " & c & " Engagement Partner: " & e & " Client Name: " & b & " Total Expense: " & h & " Charged Hours: " & j & " TER: " & m & " NER: " & n & " SER: " & o, , ("Results")
End Sub

If anyone can help rebuild my code or at least tell me how to better explain myself I'd love to learn! VBA feels **** rewarding when you get something right!

-Matt
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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