Highlight specific cells immediately after a copy and paste

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I am using an advance filtering VBA process where the results are immediately pasted to another worksheet. I have a series of these events happening I would like like the highlight to appear as I go rather than try to highlight these cells before unattended highlights occur if I try and do this all at once after the mass filtering is complete. I attached two macros, the first one is where the highlight in yellow would like to occur. The second macro is there for context. The macro that occurs after the second macro is one that clears the first macro and sets up the next. In the example below I would only want E in C2 and USA in H2 to be highlighted. Those letters in those columns may appear elsewhere outside that particular group on the worksheet, but in that case I wouldn't need them highlighted since the advance filter would be looking for something else.


VBA Code:
Sub DEPEML_CatIV()
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "E"
    Range("H2").Select
    ActiveCell.FormulaR1C1 = "USA"
  End Sub


VBA Code:
Sub DEPEML_CatIV_Filter()
Dim rgData As Range, rgCriteria As Range, rgOutput As Range
Dim sh As Worksheet
Dim LstRw As Long
Set rgData = ThisWorkbook.Worksheets("Database").Range("A6").CurrentRegion
Set rgCriteria = ThisWorkbook.Worksheets("Database").Range("A1").CurrentRegion
Set rgOutput = ThisWorkbook.Worksheets("Deficiencies").Range("A1")
Set sh = Sheets("Deficiencies")
With sh
LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row + 2
Set rgOutput = .Range("A" & LstRw)
rgData.AdvancedFilter xlFilterCopy, rgCriteria, rgOutput
End With

End Sub
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,238
I'm not sure that I quite follow but does this do what you want?
VBA Code:
Sub DEPEML_CatIV()
    Range("C2") = "E"
    Range("H2") = "USA"
    Range("C2,H2").Interior.ColorIndex = 6
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,126,994
Messages
5,622,053
Members
415,875
Latest member
Tarali

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
Top