Pass inputbox string to message box Run-time Error 13

Nadine67

Board Regular
Joined
May 27, 2015
Messages
225
Hello and thank you for any attention my post may receive.

I am trying to pass the results from a input box to a ws and message box.

It works fine with pasting to the ws, however returns and error for the message box.

Any help will be greatly appreciated.

Code:
Private Sub test()
Dim s As Worksheet
Dim ar, dar, colar As Variant, x%, k%, i%, j%, cac%, slr%
Dim tra2 As String, tra As String

Set s = Sheets("SIF Reference Hidden")
tra = InputBox("Enter Tag Number", "Transmitter Tag Entry")
colar = Array(4)
cac = UBound(colar)
slr = s.Cells(Rows.Count, 4).End(xlUp).Row
x = Application.CountIf(s.Cells(1, 2).Resize(slr), tra) ' input box
ar = s.Cells(1, 1).Resize(slr, 4).Value
ReDim dar(x - 1, cac)
k = 0
For i = 1 To slr
    If ar(i, 2) = tra Then
        For j = 0 To cac
            dar(k, j) = ar(i, colar(j))
        Next j
            k = k + 1
        Else
    End If
Next i
Sheets("test").Cells(4, 1).Resize(k, cac + 1).Value = dar

MsgBox "list: " & vbNewLine & vbNewLine & dar, vbInformation, "Welcome"
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
What does dar return when you hover over it in the message box line ??
 
Upvote 0
Hello Michael

Currently I don't get to the Message Box because the code only gets as far as poulating the worksheet. 'dar' returns the array list of matches to the worksheet but not the message box.

If I enter ‘abc123’ in the input box, then ‘dar’ returns a list of results – a bit like a list of every FIND MATCH OFFSET instance.

The code returns the correct result on the worksheet, but I am unable to pass the list directly to a message box. I am only using the worksheet as a test for correctness, and ideally I would like to pass the resulting list directly to the message box.
 
Last edited:
Upvote 0
Nadine

What are the dimensions of the array you want to display in the message box?
 
Upvote 0
Hello Norie

The array is the values in column four for each match found in column two.

Have a great day!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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