PC Review


Reply
Thread Tools Rate Thread

Data Matching and exporting

 
 
swiftcode
Guest
Posts: n/a
 
      15th Jan 2009
Hi all,

i have 2 sheets in a workbook with similar fields, which i read in using
vba, and try to match specific fields before throwing both sets of data to
abother sheet. my problem is that the first sheet of data comes in a 1 line
format, whilst the 2 sheet comes in multiple lines, can i have the first
sheet matched line to match off against multiple lines in the 2nd sheet?

Does anyone have any idea how i can change (also improve) what i have
written below to achieve this. All the fields (cells) have same data except
the price, which is summed in the 1st sheet but broken up in the 2nd.


Sub Recon()

Sheets("B Details").Select
Cells.Find(What:="T.Date", _
After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:= _
xlByRows, SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False) _
.Activate
BeginRow = ActiveCell.Row + 1

Range("A65535").End(xlUp).Select
EndRow = ActiveCell.Row

For E = BeginRow To EndRow Step 1
Sheets("B Details").Select
Cells(E, 1).Select
TradeDate = Cells(E, 1).Value
Price = Cells(E, 2).Value
ContractDate = Cells(E, 4).Text
Matcher = Left(Cells(E, 16), 7)

Sheets("F Details").Select
Cells.Find(What:="T. Date", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, SearchOrder:= _
xlByRows, SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False) _
.Activate
BeginRow1 = ActiveCell.Row + 1

Range("A65535").End(xlUp).Select
EndRow1 = ActiveCell.Row

For F = BeginRow1 To EndRow1 Step 1
Sheets("F Details").Select
Cells(F, 20).Select
TradeDate_U = Cells(F, 1).Value
Price_U = Cells(F, 2).Value
ContractDate_U = Cells(F, 6).Text
Matcher_U = Left(Cells(F, 16), 7)

If TradeDate = TradeDate_U And ContractDate = ContractDate_U _
And Matcher <> "Matched" And Matcher_U <> "Matched" Then

Sheets("B Details").Select
Cells(E, 16).Value = "Matched B" & Counter
Sheets("B&F Details").Select
Cells(F, 16).Value = "Matched B" & Counter

Sheets("Matched").Select
Range("A65535").End(xlUp).Select
EndRowMatch = ActiveCell.Row
Cells(EndRowMatch + 1, 1).Select
Cells(EndRowMatch + 1, 1).Value = TradeDate
Cells(EndRowMatch + 1, 2).Value = ContractDate
Cells(EndRowMatch + 1, 3).Value = Price
Cells(EndRowMatch + 1, 4).Value = "Matched B" & Counter
ActiveCell.EntireRow.Interior.ColorIndex = 38

Cells(EndRowMatch + 2, 1).Select
Cells(EndRowMatch + 2, 1).Value = TradeDate_U
Cells(EndRowMatch + 2, 2).Value = ContractDate_U
Cells(EndRowMatch + 2, 3).Value = Price_U
Cells(EndRowMatch + 2, 4).Value = "Matched B" & Counter
ActiveCell.EntireRow.Interior.ColorIndex = 37

Counter = Counter + 1
Exit For
Else
End If

Next F
Next E
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
Display non-matching data in a report and don't display matching d Dominick D. Microsoft Access VBA Modules 4 30th Apr 2008 07:07 PM
Matching a column of new data to existing larger data set. Sirjay Microsoft Excel Worksheet Functions 1 21st Apr 2008 05:05 PM
Matching identical data using data only once in the matching proce =?Utf-8?B?Um9iZXJ0IDE=?= Microsoft Excel Misc 1 29th Jun 2007 04:22 PM
Joining Fields With Similar Data (But Not Exactly Matching Data) neilisou@gmail.com Microsoft Access Queries 5 2nd Mar 2007 02:21 PM
How can I confirm correct data entry using a second matching data field moe leaer via AccessMonster.com Microsoft Access Database Table Design 3 13th Dec 2004 11:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:37 AM.