Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro question

Status
Not open for further replies.

jmuscat

Instructor
May 22, 2002
54
AU
I want a macro to find a specific word say in column A,then pick up the amount of the next column (b) of the same row and return the amount to another column say H.
The problem is that the place where I want the amount to go will always change, but would be at the next available blank row in Column H.
Can anyone help with code?
jmuscat
 
jmuscat,

I've created a working example for you. If you'd prefer, you can email me and I'll send the file via return email.

Here are the steps I took.

1) Assigned the range name "colmAB" to columns A:B

2) Assigned the range name "inp" to cell C2

3) Entered the following formula in cell D2
=VLOOKUP(inp,colmAB,2,FALSE)

4) Added a macro button, and named it "Add to List"

5) Attached the following VBA routine to the macro button...

Sub AddToList()
curnum = Range("num").Value
If IsError(curnum) Then Exit Sub
If curnum = "" Then Exit Sub
NextCell = [H65536].End(xlUp).Offset(1, 0).Address
Range(NextCell).Value = curnum
Range("inp").ClearContents
End Sub

I hope this is what you were seeking. :) Please advise as to how it fits. Or if you'd prefer the file, email me - use BOTH addresses below to ensure you reach me.

Regards, ...Dale Watson

HOME: nd.watson@shaw.ca
WORK: dwatson@bsi.gov.mb.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top