Simple Number Search Difficulty

Craw

New Member
Joined
Jul 27, 2011
Messages
32
Greetings,
I am trying to creget this code to work. It works when i'm searching for text but I can't seem to get it to search for numerical values such as an ID number.

Private Sub idsearch_Click()

Dim strName As String
Dim caption As String
Dim Prompt As String

Prompt = "What ID Number Would You Like to Search For?"
caption = "ID Number Search"

strName = Val(InputBox(Prompt, caption))
Range("Table_owssvr_1[ID]").Select
Selection.AutoFilter Field:=1, Criteria1:="strName", Operator:=xlAnd


End Sub

Any ideas on how to fix it?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try removing the quotes

Rich (BB code):
Private Sub idsearch_Click()

Dim strName As Variant
Dim caption As String
Dim Prompt As String

Prompt = "What ID Number Would You Like to Search For?"
caption = "ID Number Search"

strName = Val(InputBox(Prompt, caption))
Range("Table_owssvr_1[ID]").Select
Selection.AutoFilter Field:=1, Criteria1:=strName, Operator:=xlAnd


End Sub
 
Upvote 0
I'm such an idiot thanks much it worked. Sometimes when you stare at a code for so long you just can't see the forest from the trees.

Regards,


Phil
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

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