Macro Help - Select Range based on User Input

SSUNBRN

New Member
Joined
Jan 19, 2005
Messages
2
Hi,

I have a data set that contains several columns of info. Within this data, unique reference numbers are stored in column B. I'm interesting in obtaining a macro that would pop up a window and allow the user to enter a reference number (e.g., 293). The macro would then select the A-I columns of the row with that reference number (e.g., A1:I1 - if 293 was in B1). Can anyone help?

Thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Welcome to the Board Sunbrn,

How about this:
Code:
Sub selectcol()
On Error Resume Next
result = InputBox("What ID would you like to select?", "ID Input")
Set c = ActiveSheet.Range("B:B").Find(result, LookIn:=xlValues)
If c Is Nothing Then
    MsgBox "The ID you entered in not on the list"
    Exit Sub
End If
Range(Cells(c.Row, 1), Cells(c.Row, 9)).Select
End Sub
 
Upvote 0
Yankee --

The code you wrote produces exactly the results that I was looking for. Thank you very much for your time and expertise.
 
Upvote 0

Forum statistics

Threads
1,203,521
Messages
6,055,883
Members
444,830
Latest member
Excelsmallbusinessmom

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