![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Arizona
Posts: 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! |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
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. |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Arizona
Posts: 68
|
I can't seem to tweak that formula to work with my spreadsheet, can I use the find method to return the cells address?
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Location: Arizona
Posts: 68
|
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! |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|