Search : in
By :

Simple If else Loop with hide row

Last answer on Apr 21, 2009 3:13:44 pm BST Ninong, on Sep 25, 2008 12:19:42 pm BST 
 Report this message to moderators

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

Best answers for « Simple If else Loop with hide row » in :
Excel - Send value of cell to target ShowExcel - Send value of cell to target Issue Solution Note Issue Is it possible to send the value of a cell (copy and paste special) to another cell where the value would not be disturbed when the source value changes to '0'? My...
Files and Folder hidden - how to fix? ShowFiles and Folder hidden - how to fix? Issue Solution Issue If you ever try accessing your partitions or flash drive, can't see any files or folders and you have checked the drive's properties and see that there's still data in it,...
Access the hidden Administrator Account in Windows Vista ShowAccess the hidden Administrator Account in Windows Vista Why has the Administrator account been disabled in Vista? How to activate the Administrator Account Solution 1: Through User Account Control Solution 2: With Command Prompt Solution...
Download Second Hide ShowDescription The application designed Second Hide Inc. Simple and easy to use, the application has been awarded from various places. It offers a simple intuitive interface. Second Hide is a tool that enables you to hide every single activity on your...
ADSL - Local loop unbundling ShowIntroduction to local loop unbundling The part of the telephone line arriving at the subscriber is called the "local loop". In order to use high speed internet (ADSL), Internet Service Providers (ISP) must install connection hardware to their...

1

Ivan-hoe, on Sep 26, 2008 7:55:02 am BST

Hello,
here is a solution in a kit form. Dare ask if you need more help.
Ivan

Use a "For Each...Next" loop :

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.

Reply to Ivan-hoe

2

 Vicky Jain, on Apr 21, 2009 3:13:44 pm BST
  • +3

Sir,
how to write a vba to remove all formula in column B and column C if the cell value in not equal to #N/A.
Thanks in Advance

Reply to Vicky Jain