Hi, I'm trying to create macros to analyze my research project data.
I'm new to VBA and don't know much so I try to record macros if it works and then get the base code and tweak it.
I have filtered my column B ("animal") to show only "z011" and "z012". I assigned the value "Control" in "C12" (First cell in this case). I need to assign these filtered rows as "Control" in Column C from the first cell ("C12" in this case), till the last cell.
This is my code currently that i managed to work out from various threads here and there. However I'm not sure what's wrong as it changes my entire sheet cells to "Control".
Sub Macrotest2()
'
' Macrotest2 Macro
'
'
ActiveSheet.Range("$A$1:$AO$12598").AutoFilter Field:=2, Criteria1:="=z011" _
, Operator:=xlOr, Criteria2:="=z012"
ActiveSheet.Range("$A$1:$AO$12598").AutoFilter Field:=2, Criteria1:="=z011" _
, Operator:=xlOr, Criteria2:="=z012"
Range("C12").Select
ActiveCell.FormulaR1C1 = "Control"
Lastrow = Range("C" & Rows.Count).End(xlUp).Row
Range("C12:C" & Lastrow).SpecialCells(xlCellTypeVisible) = Range("C12").Value
End Sub
Bookmarks