Match value from input box with value in column

chouston

Board Regular
Joined
Apr 24, 2002
Messages
68
Hi, I have a spreadsheet that has hundreds of rows that include a unit number, a name, and several charges generated by the sheet.

I'm trying to set-up a vba program that prompts user for a unit number, then finds that cell that matches the input(ed) unit number and then pulls the name and charges from the corresponding row.

I've got the input box and the message box done, but am having trouble looping through the cells in the unit column (I'm still very new at VBA).

Thanks alot for any help!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I would just do something like this ( I haven't tested it, so beware ):

sub test()
dim xcol as integer
dim xrow as integer
dim gogo as integer
gogo = 1
xcol = 1
xrow = 1
do while len(cells(xrow, xcol)) and gogo
if cells(xrow, xcol).value = msgboxvalue then
gogo = 0
end if
xrow = xrow + 1
loop
end sub

This "should" give you the column number and row number of the specified value in the inputbox.
 
Upvote 0
I can't seem to tweak that formula to work with my spreadsheet, can I use the find method to return the cells address?
 
Upvote 0
I figured out a solution!

For those interested:

'This starts the final bill procedure
'prompt for unit number and move-out date
unit = InputBox("Enter Unit #:", "Final Billing Form")
Date = InputBox("Move out date?", "Final Billing Form")
'

'find row for that unit number
With Sheets("Ridge Download").Range("B43:B422")
resrow = .Find(unit).Row
End With

res = ActiveWorkbook.Sheets("Ridge Download").Cells(resrow, 6)

etc....

Thanks for you help zacemmel!
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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