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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macro

Status
Not open for further replies.

williards

Technical User
Jan 27, 2003
4
0
0
US
I'm trying to populate a cell in a "Location" column with text from a different worksheet, based on a common
"Equipment No." I.E.-

Worksheet 1 has a Column C (Equipment No.) with multiple occurrences of Equipment No. 12345. It also has a Column D (Location) that is not poplulated.

Worksheet 2 has Equipment No. 12345 in Cell A2 and Location for 12345 in Cell B2.

How do I populate Column D cells with the proper location (from Cell B2 of worksheet 2) for each occurrence of Equipment No. 12345 in Column C?
 
Willards
Take a look at Excels VLookup function ... that will find the occurance of any matching search criteria, then just do an ActiveCell.Offset (I think it should be 0,1)copy that and paste or set a reference to that cell. If you need help in getting this to work, let us know, someone will work it out.
 
I guess I don't know enough about Excel or Visual Basic to understand your answer. I looked at VLookup but it didn't seem to fit what I want to do. A macro is what I use to perform an action on some data, right? So, I will need to build a macro to do the transfer of data from one worksheet to the other? Then I use the Visual Basic commands to configure the macro for the way I want it to work? Sorry, but I'm really new to this programming stuff...just getting my feet wet.

Do you have an example of what you're suggesting? I don't think I even know enough to get started...
 
This is probably a simple Excel answer and you will get better responses in the Excel or Mocrosoft office forum.

I note that this was suggested to you earlier in the VBA forum!

See faq222-2244 to get the best from the forums
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Williards, A macro is a recorded set of actions, primarily used to automatically perform something that requires several mouse clicks and/or keystrokes. VBA is actual coding behind controls used to perform some action based on a control event. I will try to work out the macro/VBA for you this afternoon.
 
I am sure I have done things like this in cell formulae, VLOOKUP and INDEX & INDIRECT (& ROW() in a cloumn of its own). Willards - I find it gets so unwieldy by at least if you take about 10 columns to formularise each step you can see which part needs attention or error handling. You can always hide those columns and have them over in the AA column region.
I like doing things like

=($A1=$B1) in col C then
=if(C1,"action","number) in col D because you can see the logic!

But that is really Excel territory rather than VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top