Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to update data

I've got source data in sheet: x
IDs are listed in C2 down,
Date of Deletion in R2 down
(data is ~ 40k rows, as per last data in ID col C)

In another sheet: z (received daily)
IDs are listed in C2 down, Date of Deletion in J2 down

I'd like to run a sub to update x's col R with the deletion dates in z's col
J for IDs in z which match those in x. For unmatched IDs, do nothing in x,
but flag these IDs in z's col K as: "ID not found". IDs are text. Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sub to update data

Sub GetDelectionDate()

With Sheets("Z")
Lastrow = .Range("C" & Rows.Count).End(xlUp).Row
For RowCount = 2 To Lastrow
ID = .Range("C" & RowCount)
Set c = Sheets("X").Column("C").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
.Range("K" & RowCount) = "ID not Found"
Else
.Range("J" & RowCount) = c.Offset(0, 15)
End If
Next RowCount
End With

End Sub


"Max" wrote:

I've got source data in sheet: x
IDs are listed in C2 down,
Date of Deletion in R2 down
(data is ~ 40k rows, as per last data in ID col C)

In another sheet: z (received daily)
IDs are listed in C2 down, Date of Deletion in J2 down

I'd like to run a sub to update x's col R with the deletion dates in z's col
J for IDs in z which match those in x. For unmatched IDs, do nothing in x,
but flag these IDs in z's col K as: "ID not found". IDs are text. Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to update data

Thanks, Joel

Tried running your sub but hit with:

RunTime error 438
Object doesn't support this property or method

Debug pointed to this line:

Set c = Sheets("X").Column("C").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)

(I'm using xl2003)


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sub to update data

should be Columns

from
Set c = Sheets("X").Column("C").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)
to
Set c = Sheets("X").Columns("C").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)


"Max" wrote:

Thanks, Joel

Tried running your sub but hit with:

RunTime error 438
Object doesn't support this property or method

Debug pointed to this line:

Set c = Sheets("X").Column("C").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)

(I'm using xl2003)



  #5   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to update data

Thanks, that fixed the error. But the sub is doing the 1st part of it in
reverse, ie it is updating z from x, when it should be the other way, update
x from z, ref:
update x's col R with the deletion dates in z's col J
for IDs in z which match those in x


The 2nd part is working fine though
For unmatched IDs, .. flag these IDs in z's col K as: "ID not found"





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sub to update data

I got one line backwards

from
.Range("J" & RowCount) = c.Offset(0, 15)
to
c.Offset(0, 15) = .Range("J" & RowCount)

"Max" wrote:

Thanks, that fixed the error. But the sub is doing the 1st part of it in
reverse, ie it is updating z from x, when it should be the other way, update
x from z, ref:
update x's col R with the deletion dates in z's col J
for IDs in z which match those in x


The 2nd part is working fine though
For unmatched IDs, .. flag these IDs in z's col K as: "ID not found"




  #7   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to update data

Many thanks. That got it going great.

I need a slight refinement, though. As x's col C may contain duplicate IDs,
the updates from z would need to update all of these cases in x's col R.
Currently the sub does update it correctly but only for the 1st instance in
x's col R. The 2nd, 3rd instances remain un-updated.


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Sub to update data

Try this. It is easier to go through each sheet seperately.

Sub GetDelectionDate()

With Sheets("Z")
LastRow = .Range("C" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
ID = .Range("C" & RowCount)
Set c = Sheets("X").Columns("C").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
.Range("K" & RowCount) = "ID not Found"
End If
Next RowCount
End With
With Sheets("X")
LastRow = .Range("C" & Rows.Count).End(xlUp).Row
For RowCount = 2 To LastRow
ID = .Range("C" & RowCount)
Set c = Sheets("Z").Columns("C").Find(what:=ID, _
LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
.Range("R" & RowCount) = c.Offset(0, 7)
End If
Next RowCount
End With


End Sub


"Max" wrote:

Many thanks. That got it going great.

I need a slight refinement, though. As x's col C may contain duplicate IDs,
the updates from z would need to update all of these cases in x's col R.
Currently the sub does update it correctly but only for the 1st instance in
x's col R. The 2nd, 3rd instances remain un-updated.



  #9   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Sub to update data

Brilliant, Joel. Thanks. Works fine.


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
Data Validation lists update orginal cell with list update [email protected] Excel Worksheet Functions 3 July 11th 08 07:56 AM
update a Pivot Table with new data added to the base data Graham Y Excel Discussion (Misc queries) 1 March 19th 07 02:12 PM
Update a chart immediately after inputting data into data source MELMEL Charts and Charting in Excel 1 December 1st 05 09:34 PM
how to update data on sheet1 and have it auto update on sheet2 Tommy Excel Programming 6 May 11th 05 06:41 PM
Date update on data update Chris Thompson Excel Programming 3 August 22nd 03 06:40 PM


All times are GMT +1. The time now is 11:22 PM.

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"