View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Roger Roger is offline
external usenet poster
 
Posts: 226
Default Quick Question - Edit Macro

Hello,

Can you help me to set this macro up so it works between 2 workbooks vs.
just working on the same sheet viewing different columns?

Im looking for Sheet1 in Workbook A to look for a Match in Sheet2 Workbook
B. Ive filled in the ranges as they would appear in each of the Workbooks.
Range(E2:E100) is the range in Workbook A looking to match Range(A2A100)
in Workbook B. If match is found, Workbook A Range (B2:B100) would copy
cell values to destination Workbook B Range(C2:C100).

Appreciate any help you can provide.

Thanks - Roger

Sub TestCopyFormat()

Dim Cell As Range
Dim Cindex As Integer
On Error GoTo errorhandler
Application.DisplayAlerts = False
With Worksheets("Sheet1")
For Each Cell In Range("E2:E100")
Cindex = WorksheetFunction.Match(Cell.Text, .Range("A2:A100"), 0)
.Range("B2:B100").Cells(Cindex, 1).Copy _
Destination:=Range("C2:C100").Cells(Cindex, 1)
Next Cell
End With
errorhandler:
Application.DisplayAlerts = True
End Sub