ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlite filtered items (https://www.excelbanter.com/excel-programming/357093-highlite-filtered-items.html)

Hugh

Highlite filtered items
 
Howdy,
Have a worksheet for entry, with a macro that copies filtered ranges to
another sheet.

Is there any way to have code to highlite only the cells in the pasted
range that contain the filter criteria?

Example: filter on Column C, 4 rows copied to sheet 2, highlight the 4
cells in Sheet 2, Column C that contain the filter criteria.
Multiple sets get copied, based on different columns being filtered.

Any help is greatly appreciated.

Ardus Petus

Highlite filtered items
 
Please post the code of your macro..

HTH
--
AP

"Hugh" not.com" a écrit dans le message de
...
Howdy,
Have a worksheet for entry, with a macro that copies filtered ranges to
another sheet.

Is there any way to have code to highlite only the cells in the pasted
range that contain the filter criteria?

Example: filter on Column C, 4 rows copied to sheet 2, highlight the 4
cells in Sheet 2, Column C that contain the filter criteria.
Multiple sets get copied, based on different columns being filtered.

Any help is greatly appreciated.




Tom Ogilvy

Highlite filtered items
 
Sub Abd()
Dim f As Filter
Dim rng As Range ' Autofilter range
Dim rng1 As Range ' Visible cells of col 1
Dim rng2 As Range ' destination
Dim rng4 As Range ' Data only in autofilter rng
Set rng = ActiveSheet.AutoFilter.Range
Set rng4 = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
Set rng1 = rng.Columns(1).SpecialCells(xlVisible)
If rng1.Count 1 Then
With Worksheets("Sheet3")
Set rng2 = .Cells(Rows.Count, 1).End(xlUp)(3)
Set rng2 = rng2.Resize(rng1.Count - 1, _
rng.Columns.Count)
End With
rng4.Copy Destination:=rng2(1)
i = 0
For Each f In ActiveSheet.AutoFilter.Filters
i = i + 1
If f.On Then
rng2.Columns(i).Interior.ColorIndex = 6
End If
Next
End If
End Sub

--
Regards,
Tom Ogilvy

"Hugh" not.com" wrote in message
...
Howdy,
Have a worksheet for entry, with a macro that copies filtered ranges to
another sheet.

Is there any way to have code to highlite only the cells in the pasted
range that contain the filter criteria?

Example: filter on Column C, 4 rows copied to sheet 2, highlight the 4
cells in Sheet 2, Column C that contain the filter criteria.
Multiple sets get copied, based on different columns being filtered.

Any help is greatly appreciated.




[email protected]

Highlite filtered items
 
Tom - that's absolutly boffo!
Many thanks!!



All times are GMT +1. The time now is 11:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com