Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2013, 10:02 PM
Registered User
 
Join Date: Jul 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy Excel data from one sheet to another by matching certain columns

Hi,

I need some help on below scenario.

I have an Excel workbook with Sheet 1 and Sheet 2

In Sheet 1 I have the following data in column A

A
--------
USA
Germany
Italy
China

In Sheet 2, I have the following data in Column A and B

A B
---------------------------
Italy 320
USA 400
China 120
Germany 50

I need a VBA code that reads the data from Sheet 2, matches Sheet 2 column A value with Sheet 1 column A value and update the value of Sheet 2 column B to Sheet 1 column B respectively.

The actual scenario is my users will be having Sheet 1 with them. Sheet 2 is actually another Excel file received from other source. My idea is to provide a code so that they can merge the values into one sheet as above.

Anyone can help on this. thanks
 
Old July 30th, 2013, 10:31 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Have you tried using Excel as a DAtabase. This would be really helpful for your scenario. Please try using ADO connection for Excel

You can also try for QueryTables

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old July 31st, 2013, 04:55 AM
Registered User
 
Join Date: Jul 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Shasur,

Its a great idea. Thanks. However I would prefer to do it using VBA code. I want to make the process as simple as possible as this will just be an supporting tool for them.
Any help ? Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy row data from one file to another based on matching column data djfscouse Excel VBA 1 August 19th, 2012 10:55 PM
Excel Macro Copy cells and pastes them in another sheet myfe Excel VBA 2 July 2nd, 2012 06:41 AM
Need a Macro for Compare and copy data from one sheet to another sheet in Excel. katnam21 Excel VBA 1 January 29th, 2012 12:09 PM
Copy specific data from one sheet to another yogeshyl Excel VBA 2 May 11th, 2007 09:14 AM
Marcro to copy data from one sheet to another Crupa Excel VBA 1 November 24th, 2004 04:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.