If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Find, Copy and Paste Macro Help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-15-10, 08:00
parmdeep parmdeep is offline
Registered User
 
Join Date: Mar 2010
Posts: 7
Find, Copy and Paste Macro Help.

I have been getting into all sort of problems using the record function and ive tried modifyin these to help but to no avail.

I have 2 workbooks with large amounts of data. I am basically taking an ID number from column B in wb1 then using Ctrl F in wb2 and after finding a match I am copying the data in Col H, AL, AR, BI and copying them into Col I, K, J, L of wb1 respectively.

I have like 1000 of these to do and I am sure a macro could help me do this faster.

Regards,

A friend in need.

Last edited by parmdeep; 03-15-10 at 08:05.
Reply With Quote
  #2 (permalink)  
Old 03-15-10, 08:17
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 477
Hi parmdeep and welcome to the forum.

A couple of questions for you -

When you search for the ID number in Wb2, will there only ever be one row of information for that ID, or could there be multiple matches? If there are multiple matches then how should they be handled?

When you search for the ID number in Wb2, are you only searching on one worksheet, or do you search through all the worksheets in that workbook?
__________________
Colin

My Excel articles

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #3 (permalink)  
Old 03-15-10, 08:25
parmdeep parmdeep is offline
Registered User
 
Join Date: Mar 2010
Posts: 7
hi thanks for the speedy response!, luckily there is only one sheet in wb2,

the id number sometimes has same information twice but its the same. so only the first match needs to be copied.
Reply With Quote
  #4 (permalink)  
Old 03-15-10, 08:54
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 477
Hi Parmdeep,

That's good news because in that case it sounds to me like you can do this using formulas, thereby avoiding the more difficult VBA solution. Have you used VLOOKUP() or INDEX() and MATCH() before? I can attach an example if required...

Hope that helps...
__________________
Colin

My Excel articles

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #5 (permalink)  
Old 03-15-10, 08:57
parmdeep parmdeep is offline
Registered User
 
Join Date: Mar 2010
Posts: 7
Hi Colin,

I havent used these functions before, (didn't even know some of those existed) an example would be extremely helpful.

Thanks,

Parm
Reply With Quote
  #6 (permalink)  
Old 03-15-10, 10:03
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 477
I've attached a workbook containing an example of each. The idea would be that you put in the formulas to pull in the values, and then copy+pastespecial values to get them hardcoded.

Because it is all contained in the same workbook, the workbook name is not contained in the formulas. If the lookup table was in another workbook then (for example) the formulas would change from:

=MATCH(C$5,'Lookup Table'!$1:$1,0)
to
=MATCH(C$5,'[Book4]Lookup Table'!$1:$1,0)

Have a look at the two examples and also have a look at the helpfile topics for these functions. Hopefully it should make sense...

Does that help?
Attached Files
File Type: zip examples.zip (5.6 KB, 10 views)
__________________
Colin

My Excel articles

Other tutorials:
Array Formulas | Deleting Rows with VBA
Reply With Quote
  #7 (permalink)  
Old 03-15-10, 11:45
parmdeep parmdeep is offline
Registered User
 
Join Date: Mar 2010
Posts: 7
cheers colin, seems like vlookup was all i needed i had a small issue with the date being displayed as a numeric value but a quick format cells fixed that issue
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On