Highlight specific cells immediately after a copy and paste

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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
 
Upvote 0

Forum statistics

Threads
1,214,626
Messages
6,120,602
Members
448,974
Latest member
ChristineC

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