Hello,
I'm making a spreadsheet where in I want to hide those rows when the cell in column d is not equal to the value in cell b1.
I just do not know what the statements for the macro should be, since i do not know anything in VB but I think here is what I want to happen..
*b1 is a selection of categories(variable)
*range of list is A3:L450
*column a is the list of items
*column c indicates what is the category of the item
go to c3
if current cell=b1 then go to the next row(same column)
else hide the current row then go to the next row(same column)
repeat this if statements while current cell is <=c450
Hello,
Dim MyCell As Range, MyRange As Range
Set MyRange = Range("C3:C450")
For Each MyCell In MyRange
'instructions
Next MyCell
The "if" statement would be : If MyCell.Value <> Range("B1").Value Then
'instructions
End If
Then, to hide a row, have a look at "Range.EntireRow" and "Range.Hidden" in the help file. To make your code run faster, think of using "Application.ScreenUpdating" (see help file) If you want your macro to run automatically when you change the selection in B1, see the help file about the events of a worksheet. |