Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Update a ListObject from a another Excel sheet

I need a bit of code please to update a ListObject from a secondary
Excel data source.

The Target (the ListObject) stucture is:
WORKBOOK: SPQuery.xls
SHEET: "CAPGCFXT"
LISTOBJECT:"List1"
A B C D E
ID SCR Descr From Date
1 22136 Demand Mike 4/29/2005
2 21517 Nortel Oliv 4/4/2005
3 15654 Douwee Tony 9/18/2006

The Source structure is:
WORKBOOK: PCVSExtract.xls
SHEET: "Sheet1"
A B C D
SCR Descr From Date
23564 Anonan Beth 9/12/2006
22136 Demand John 4/29/2005
21517 Nortel Oliv 4/4/2005

What I need it to do is:
- Remove list items from the target if they are not in the source
- Add new list items to the Target from the source
- Update cell values in the Target based on the source (if necessary)

Using the above example the following would happen in the target:
- Row 4 (15654) would be removed from the target
Presumably using some code like:
ListObjects("List1").ListRows(3).Delete
- A new row would be added based on the contents of Row 2 (23564)
Presumably using some code like: ListObjects("List1").ListRows.Add
- Row 1 (22136) would see the value in column D updated from "Mike" to
"John"

Some pointers:
- The lists are not sorted to begin with.
- The ID Column is read-only since it's a ListObject
- The SCR column contains unique record identifiers
- There is a total of 13 columns to deal with excluding the ID column
- The order of the columns in the source and target are the same
(barring the absence of an ID column in the Target)

In the above example the following would happen in the target:
- Row 4 (15654) would be removed from the target
Presumably using some code like:
ListObjects("List1").ListRows(3).Delete
- A new row would be added based on the contents of Row 2 (23564)
Presumably using some code like:
ListObjects("List1").ListRows.Add
- Row 1 (22136) would see the value in column D updated from "Mike" to
"John"

Thanks a bunch!

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
How to update an excel sheet dynamically from another excel sheet? Mona Excel Discussion (Misc queries) 3 July 12th 08 04:42 PM
Excel 2003 ListObject question Frederick Chow Excel Programming 2 March 1st 06 08:52 AM
ListObject in Excel 2000 ? NJ Excel Guru Excel Discussion (Misc queries) 1 November 15th 05 12:40 PM
reference vsto Excel ListObject in Vb.Net 2005 project/app softengine Excel Programming 0 September 27th 05 08:21 PM
saving excel sheet from ASP update Paul W.Schu Excel Programming 1 August 9th 03 11:48 AM


All times are GMT +1. The time now is 05:47 AM.

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

About Us

"It's about Microsoft Excel"