Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Macro to check 2 lists and copy data

Hi,

I was hoping that someone would be able to help me with the this?
I have a master spreadsheet and an update that is sent on a dailey basis. In
column a in the master spreadsheet is the unique reference:

A
M1
M2
M3
etc this goes does to M150

In the updates I received only some of these are included. again in the
update the reference is in column A and the updated info is in column B

I know that this can be done with vlookups but want to use a Macro instead
if this is possible.

Any help is greatly appreceiated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro to check 2 lists and copy data

Change names of Update sheet and Master Sheet as required

Sub combinedata()


Set MasterSht = Sheets("Master")
Set UpdateSht = Sheets("Update")

With UpdateSht
RowCount = 1
Do While .Range("A" & RowCount) < ""
Data = .Range("A" & RowCount)
Set c = MasterSht.Columns("A").Find(what:=Data, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
MsgBox ("Could not find : " & Data)
Else
c.Offset(0, 1) = .Range("B" & RowCount)
End If
RowCount = RowCount + 1
Loop
End With

End Sub

"Arran" wrote:

Hi,

I was hoping that someone would be able to help me with the this?
I have a master spreadsheet and an update that is sent on a dailey basis. In
column a in the master spreadsheet is the unique reference:

A
M1
M2
M3
etc this goes does to M150

In the updates I received only some of these are included. again in the
update the reference is in column A and the updated info is in column B

I know that this can be done with vlookups but want to use a Macro instead
if this is possible.

Any help is greatly appreceiated

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Macro to check 2 lists and copy data

Hi Joel,

Thank you for your response, this is a great help but I forgot to mention
that they are in different workbooks

"Joel" wrote:

Change names of Update sheet and Master Sheet as required

Sub combinedata()


Set MasterSht = Sheets("Master")
Set UpdateSht = Sheets("Update")

With UpdateSht
RowCount = 1
Do While .Range("A" & RowCount) < ""
Data = .Range("A" & RowCount)
Set c = MasterSht.Columns("A").Find(what:=Data, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
MsgBox ("Could not find : " & Data)
Else
c.Offset(0, 1) = .Range("B" & RowCount)
End If
RowCount = RowCount + 1
Loop
End With

End Sub

"Arran" wrote:

Hi,

I was hoping that someone would be able to help me with the this?
I have a master spreadsheet and an update that is sent on a dailey basis. In
column a in the master spreadsheet is the unique reference:

A
M1
M2
M3
etc this goes does to M150

In the updates I received only some of these are included. again in the
update the reference is in column A and the updated info is in column B

I know that this can be done with vlookups but want to use a Macro instead
if this is possible.

Any help is greatly appreceiated

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro to check 2 lists and copy data

the code below assumes the two workbooks are open. It is possible to modify
the code to automatically open and close the workbook(s).


from
Set MasterSht = Sheets("Master")
Set UpdateSht = Sheets("Update")
to
Set MasterSht = workbooks("book1.xls").Sheets("Master")
Set UpdateSht = workbooks("book2.xls").Sheets("Update")

or
Set MasterSht = workbooks("book1.xls").Sheets("Master")
Set UpdateSht = Thisworkbook.Sheets("Update")

"Arran" wrote:

Hi Joel,

Thank you for your response, this is a great help but I forgot to mention
that they are in different workbooks

"Joel" wrote:

Change names of Update sheet and Master Sheet as required

Sub combinedata()


Set MasterSht = Sheets("Master")
Set UpdateSht = Sheets("Update")

With UpdateSht
RowCount = 1
Do While .Range("A" & RowCount) < ""
Data = .Range("A" & RowCount)
Set c = MasterSht.Columns("A").Find(what:=Data, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
MsgBox ("Could not find : " & Data)
Else
c.Offset(0, 1) = .Range("B" & RowCount)
End If
RowCount = RowCount + 1
Loop
End With

End Sub

"Arran" wrote:

Hi,

I was hoping that someone would be able to help me with the this?
I have a master spreadsheet and an update that is sent on a dailey basis. In
column a in the master spreadsheet is the unique reference:

A
M1
M2
M3
etc this goes does to M150

In the updates I received only some of these are included. again in the
update the reference is in column A and the updated info is in column B

I know that this can be done with vlookups but want to use a Macro instead
if this is possible.

Any help is greatly appreceiated

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro code to check & copy columns mercedes[_4_] Excel Programming 2 October 6th 05 01:52 AM
Check box - if ticked copy data from one sheet to another automati rickerscote Excel Discussion (Misc queries) 0 April 14th 05 09:25 AM
Use macro to check a range of cells within a row and copy wanted data to new sheet busspeed[_3_] Excel Programming 1 September 29th 04 03:59 PM
Use macro to check a range of cells within a row and copy wanted data to new sheet busspeed[_2_] Excel Programming 0 September 29th 04 03:15 PM
Use macro to check a range of cells within a row and copy wanted data to new sheet busspeed Excel Programming 2 September 29th 04 02:55 PM


All times are GMT +1. The time now is 03:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"