Match a cell with dynamic range of columns

bgonen

Active Member
Joined
Oct 24, 2009
Messages
264
With the code below I am able to match cell A1 in worksheet:"DataByCC" with values range on column A to the last used cell on that column (col A)
If there is a match then I copy the entire row on the other Workshhets to DataByCC

The only eDIT/CHANGE I am trying to do is do the match (cell A1 in DataByCC) with columns A through F,,,if there is a match just copy the entire row to "DataByCC"

I hope someone can help
Thanks
bg

Dim LR As Long, i As Long, ws As Worksheet, j As Long
Dim k%, NextRow&
Application.ScreenUpdating = False
Sheets("DataByCC").UsedRange.Offset(1).ClearContents
For Each ws In Sheets(Array("REVENUE", "PAYROLL", "Benefits"))
With ws
Select Case .Name
Case "CapEX": j = 13
Case Else: j = 9
End Select
LR = .Range("A" & Rows.Count).End(xlUp).Row
For i = j To LR
With .Range("A" & i)
If IsNumeric(Application.Match(.Value, Sheets("DataByCC").Columns("A"), 0)) Then
On Error Resume Next
.EntireRow.SpecialCells(12).Copy
Sheets("DataByCC").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
On Error GoTo 0
End If
End With
Next i
End With
Next ws
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,603
Messages
6,179,853
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top