There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Business Applications
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Need Help Writing a Macro for Excel to Move Data From One Spreadsheet to Anot


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
macgirl27's Avatar
Computer Specs
Junior Member with 4 posts.
 
Join Date: Jul 2008
Location: Destin, FL
Experience: Advanced
22-Jul-2008, 05:17 PM #1
Cool Solved: Need Help Writing a Macro for Excel to Move Data From One Spreadsheet to Anot
I need to write a macro that will copy data from one spreadsheet into a separate spreadsheet (not in the same file). Here is the scenario...

On the first spreadsheet I have a customer's name in one column and a customer's address in another column. On a separate spreadsheet a have those same customer's names without the addresses. On the second spreadsheet the customer's name may be listed more than once. What I need to do is add the corresponding address to the second spreadsheet beside the name of the customer (identical data from both spreadsheets). The reason copy and paste won't work is because the customer may appear numerous times on the second spreadsheet and their are approximately 50,000 rows of data.

The macro needs to basically say IF Spreadsheet 1, Column A (customer) equals Spreadsheet 2, Column G (customer) then ADD/REPLACE info from Spreadsheet 1, Column B (address) to Spreadsheet 2, Column H (currently blank). I just can't figure out how to make it do that. ANY HELP ANYONE CAN GIVE IS APPRECIATED!
Squashman's Avatar
Distinguished Member with 12,597 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
22-Jul-2008, 07:10 PM #2
Might want to ask the moderators to move this thread to the Business Applications section. That is where they deal with most of these types of questions.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,843 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
23-Jul-2008, 02:11 PM #3
You don't really need a macro. If you have your list of names and addresses in a book called Book2 on Sheet1 in columns A and B and the list of names only in column A of Sheet1 in Book1, enter this formula in cell B1 on Sheet1 of Book1 (next to the names):
=VLOOKUP(A1,[Book2.xls]Sheet1!$A:$B,2,0)
This tells excel to look in Book2, Sheet1 for the values.
If you do not have Book2 open when you open Book1 you will get a warning that the formula is trying to update from an outside source - click okay. This will actually alter the formula by inserting the full address for the Excel book it is linked to - in this case, Book2.
Thus, it changed my formula to
=VLOOKUP(A1,'C:\Documents and Settings\username\Desktop\[Book2.xls]Sheet1'!$A:$B,2,0)

If you prefer, you can Copy all of the addresses found in this way then Paste Special, Values back in - that will replace the formula with the actual addresses.
__________________
Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime.

My theme song...
macgirl27's Avatar
Computer Specs
Junior Member with 4 posts.
 
Join Date: Jul 2008
Location: Destin, FL
Experience: Advanced
23-Jul-2008, 02:25 PM #4
Thank you so much! I've been beating my head against the wall writing every "IF" formula I could think of and I couldn't make it work. Your solution worked like a charm.
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,843 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
23-Jul-2008, 02:51 PM #5
Glad to help - welcome to the forum!!!
slurpee55's Avatar
Computer Specs
Distinguished Member with 3,843 posts.
 
Join Date: Oct 2004
Location: Southwest Iowa....
Experience: Currently stupid...
23-Jul-2008, 02:57 PM #6
There's probably some way to do it with an Index, Match, but it isn't coming to me.
Reply

Tags
excel, macro


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:27 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.