I am in need of help with VBA code.I am pretty new to VBA and can't find a solution to a problem with selecting first visible cell, above the header, in a column, after filtering. I want to select this cell to set its value to "x" and then i need to put "x" for every filtered row in my table. Mabye you know the way to make it easier by selecting visible cells in column BK and put "x" in them? This column has only blank cells.
Any help will be greatly appreciated.
My code looks like this:
Sub Filter_and_insert()
'
' Filter_and_insert Makro
'
'Select an active worksheet
Sheets("DANE PIPELINE 29.10").Select
' First filter I use for data
ActiveSheet.Range("$A$3:$BQ$4773").AutoFilter Field:=40, Criteria1:=Array( _
"C.O.R.", "Contract", "Positive Quote", "Quote", "Selling"), Operator:= _
xlFilterValues
' Second filter I use for data
ActiveSheet.Range("$A$3:$BQ$4773").AutoFilter Field:=25, Criteria1:= _
"Not assigned"
' Here I need to select first visible cell above header after filtering and set its
' value to "x".
' Range ("BK36") is only for this current data and it will be different for
' other data so thats why I need to find first visible cell.
Range("BK36").Select
ActiveCell.Value = "x"
' Here I am selecting all filtered cells in a row and fill them with "x"
ActiveCell.Offset(0, -20).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 20).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
' Reset filters
Selection.AutoFilter Field:=40
Selection.AutoFilter Field:=25
End Sub
Thanks very much for all the help in advance.
This will place an "x" in each visible cell in column BK
Sub MarkX()
Dim rX As Range
Set rX = Intersect(ActiveSheet.UsedRange, Range("BK:BK")).Cells.SpecialCells(xlCellTypeVisible)
rX.Value = "x"
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.