Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default update Records reference to new file

hi
I want to update AGE field in file A from file b. i.e update AGE.

The number of records in file A and File B are not equal and may be
different value.

this is what i want
If there is any new name if file b add it in file a. For all other Name
which are in file a and file b, just take the new AGE from file B and
update in file A.

file a (it has 5 colomn)
Name Number Field Qty Age
John 7878 8989 234 32
Peter 7877 23 9 NA
Mike 3433 343 --
Shart 343 343
William 323 52 5

file b (it has only two colomn)

name AGE
John 34
Peter NA
Mike NA
Josh 43
ASA NA
MOM 11

any advice on it.

thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default update Records reference to new file

Will need to use a combination of

COUNTIF() &
VLOOKUP()

in a Macro.

Ant

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default update Records reference to new file

This should do it

::::::::::::::::::::::::::::

Sub AddEntries()

Set qrange = Workbooks("File A").Sheets("Sheet1").Range("A:A")
Set prange = Workbooks("File B").Sheets("Sheet1").Range("A:b")
Sheets("Sheet1").Range("A2").Select

Do Until IsEmpty(ActiveCell)
On Error Resume Next
ActiveCell.Offset(0, 4).Value = _
Application.WorksheetFunction.VLookup(ActiveCell.V alue, prange, 2, 0)
ActiveCell.Offset(1, 0).Select
On Error GoTo 0
Loop


Windows("File B").Activate
Sheets("Sheet1").Range("A2").Select

Do Until IsEmpty(ActiveCell)
qname = ActiveCell.Value
qage = ActiveCell.Offset(0, 1).Value

If Application.WorksheetFunction.CountIf(qrange, qname) = 0 Then
Windows("File A").Activate
ActiveCell.Value = qname

ActiveCell.Offset(0, 4) = qage
ActiveCell.Offset(1, 0).Select

Windows("File B").Activate
End If
ActiveCell.Offset(1, 0).Select

Loop

End Sub


:::::::::::::::::::::::::::::::::::::::

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default update Records reference to new file

This should do it

::::::::::::::::::::::::::::

Sub AddEntries()

Set qrange = Workbooks("File A").Sheets("Sheet1").Range("A:A")
Set prange = Workbooks("File B").Sheets("Sheet1").Range("A:b")
Sheets("Sheet1").Range("A2").Select

Do Until IsEmpty(ActiveCell)
On Error Resume Next
ActiveCell.Offset(0, 4).Value = _
Application.WorksheetFunction.VLookup(ActiveCell.V alue, prange, 2, 0)
ActiveCell.Offset(1, 0).Select
On Error GoTo 0
Loop


Windows("File B").Activate
Sheets("Sheet1").Range("A2").Select

Do Until IsEmpty(ActiveCell)
qname = ActiveCell.Value
qage = ActiveCell.Offset(0, 1).Value

If Application.WorksheetFunction.CountIf(qrange, qname) = 0 Then
Windows("File A").Activate
ActiveCell.Value = qname

ActiveCell.Offset(0, 4) = qage
ActiveCell.Offset(1, 0).Select

Windows("File B").Activate
End If
ActiveCell.Offset(1, 0).Select

Loop

End Sub


:::::::::::::::::::::::::::::::::::::::

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
Form Lookup & Update Records Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:55 PM
draw 999 x 8 random records from file with 8614 records news.wanadoo.nl Excel Programming 1 March 1st 06 03:04 PM
Update yearly records ED Excel Discussion (Misc queries) 1 January 19th 06 10:08 PM
How can I update a spreadsheet for a new season of records? Linda Excel Discussion (Misc queries) 2 September 13th 05 05:12 PM
how do I update a spreadsheet without duplicating records? ACWebgoddess Excel Programming 1 August 30th 04 10:48 PM


All times are GMT +1. The time now is 07:55 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"