PC Review


Reply
Thread Tools Rate Thread

Copying Data between Spreadsheets based on a rows value

 
 
Phil Gold
Guest
Posts: n/a
 
      1st Dec 2009
Hi there,

Looking for a bit of assistance in Excel with VB macro.
I have 2 spreadsheets. One has an order number and a few cells of data. The second has a column of order numbers and each row has data regarding that order. I am looking for code that will run when an on screen button is pressed that grabs the order number and data from the first spreadsheet and then in the new spreadsheet look for the row which has the same order number (In say column A) and paste the data in another column in that row (Say column M).

EG.
Spreadsheet 1
Order Number Data1 Data2 Data3
5468 #new# #new# #new#


Spreadsheet 2
Order Number DataA DataB Data1 Data2 Data3
2245
6315
5468 existing data #new# #new# #new#

Any help is much appreciated.

Regards

Phil



Submitted via EggHeadCafe - Software Developer Portal of Choice
Yet Another Service Wrapper: The Ultimate Service
http://www.eggheadcafe.com/tutorials...ice-wrapp.aspx
 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      2nd Dec 2009
Hi Phil

The following procedure does what you want but you will have to change
the variables (workbook name, cell the data starts in). It assumes
you place the cursor in the cell where the Order number in Sheet 1.
If the order number is in a specific cell you may change to suit. It
also assumes you are only copying 7 columns of data in line with your
example.

Anyways I hope it helps.

Take care

Marcus


Option Explicit
Sub MovetoNew()
Dim N As Integer
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim i As Integer
Dim MyFind As String

Set WB1 = Workbooks("StBk.xls") 'change to suit
Set WB2 = Workbooks("EndBk.xls") 'change to suit
MyFind = ActiveCell.Value

If MyFind = "" Then
MsgBox "Place cursor in the Order field."
Exit Sub
End If

Range(Cells(2, 1), Cells(2, 7)).Copy
WB2.Sheets("sheet1").Activate
i = Cells.Find(MyFind, LookIn:=xlValues).Row
WB2.Sheets("Sheet1").Cells(i, 1).PasteSpecial xlPasteValues

End Sub
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help please inserting multiple rows based on cell value then copying to data sheet tech@netsoft.net.nz Microsoft Excel Worksheet Functions 1 1st Jul 2007 08:44 PM
Copying Data Between Two Spreadsheets =?Utf-8?B?Qm9i?= Microsoft Excel Programming 6 5th Jul 2006 05:37 PM
Copying Data Between Two Spreadsheets =?Utf-8?B?Qm9i?= Microsoft Excel Programming 5 29th Jun 2006 06:35 PM
Copying Data from various spreadsheets STEVEB Microsoft Excel Programming 0 6th Jan 2006 04:51 PM
Copying rows of data based on a value in a cell. Screamerz Microsoft Excel Programming 4 16th Dec 2004 01:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:50 AM.