P
Pops Jackson
I have data from two sources being pasted into columns A, B and C of a new
spreadsheet. Column A contains the account number, B the customer name and C
a description of the transaction, including the customer name. I have a
routine which finds the first occurence and pasted the account number into
column D but I need it to continue and do so for all occurences. I am using
the following which runs perfectly for one project but needs modifying for
the curent one.
Sub abc()
Windows("FXDH.xls").Activate
Sheets("FXDH").Activate
Dim rngA As Range, rngB As Range
Dim rng As Range, cell As Range
Dim res As Variant
With Worksheets("Sheet1")
Range("D").Select
Selection.Copy
Sheets("Sheet1").Activate
Range("B1").Select
ActiveCell.PasteSpecial
Application.CutCopyMode = False
Workbooks.Open ("T:\Fxbckoff\FXVolumeRpts\Customers.xls")
Sheets("qryCustomers").Activate
Range("A:A").Select
Selection.Copy
Windows("FXDH.xls").Activate
Sheets("Sheet1").Activate
Range("A1").Select
ActiveCell.PasteSpecial
Application.CutCopyMode = False
Stop
Set rngA = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
Set rngB = .Range(.Cells(2, 2), .Cells(2, 2).End(xlDown))
End With
For Each cell In rngA
res = Application.Match("*" & cell.Value & "*", rngB, 0)
If Not IsError(res) Then
Set rng = rngB(res)
rng.Font.Color = RGB(255, 0, 0)
rng.Font.Bold = True
rng.Offset(0, 1) = cell.Offset(0, 0).Value
End If
Next
End Sub
How can I modify this to find all occurences?
Thanks,
Jim
spreadsheet. Column A contains the account number, B the customer name and C
a description of the transaction, including the customer name. I have a
routine which finds the first occurence and pasted the account number into
column D but I need it to continue and do so for all occurences. I am using
the following which runs perfectly for one project but needs modifying for
the curent one.
Sub abc()
Windows("FXDH.xls").Activate
Sheets("FXDH").Activate
Dim rngA As Range, rngB As Range
Dim rng As Range, cell As Range
Dim res As Variant
With Worksheets("Sheet1")
Range("D").Select
Selection.Copy
Sheets("Sheet1").Activate
Range("B1").Select
ActiveCell.PasteSpecial
Application.CutCopyMode = False
Workbooks.Open ("T:\Fxbckoff\FXVolumeRpts\Customers.xls")
Sheets("qryCustomers").Activate
Range("A:A").Select
Selection.Copy
Windows("FXDH.xls").Activate
Sheets("Sheet1").Activate
Range("A1").Select
ActiveCell.PasteSpecial
Application.CutCopyMode = False
Stop
Set rngA = .Range(.Cells(2, 1), .Cells(2, 1).End(xlDown))
Set rngB = .Range(.Cells(2, 2), .Cells(2, 2).End(xlDown))
End With
For Each cell In rngA
res = Application.Match("*" & cell.Value & "*", rngB, 0)
If Not IsError(res) Then
Set rng = rngB(res)
rng.Font.Color = RGB(255, 0, 0)
rng.Font.Bold = True
rng.Offset(0, 1) = cell.Offset(0, 0).Value
End If
Next
End Sub
How can I modify this to find all occurences?
Thanks,
Jim