View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
shabutt shabutt is offline
external usenet poster
 
Posts: 31
Default Hiding entire row(s) on entering data in cell(s)

Hi,

Thank you very much for quick reply. "OssieMac" your code works like a charm
and it's so simple to understand as well. I am really grateful.

Regards.

"OssieMac" wrote:

Hi Shabutt,

Probably need a little more information but here goes my first attempt.

Do I understand correctly that the Salary column has blank cells where the
data is to be entered? If so, is there any reason that the salary column
filter cannot be set to blanks?

If the salary column can be set to blanks then it is possible to force
refiltering each time a change is made to the Salary column.

Just right click on the sheet name tab and select View Code and copy and
paste the following macro into the VBA editor. You will need to edit the code
to insert the correct column number and also the correct filter number.

To get the correct filter number and code, turn on the macro recorder and
set the salary filter to blanks and then turn off the recorder and you will
have the required line of code. (It will be in Module1 of the VBA editor.
Copy just the line of code from there to replace the filter setting line of
code in the sheet module where you place the following macro.)

Private Sub Worksheet_Change(ByVal Target As Range)

'Edit as per instructions above. (change column 6 to your Salary column
number)
If Target.Column = 6 Then
Selection.AutoFilter Field:=6, Criteria1:="="
End If

End Sub

--
Regards,

OssieMac


"shabutt" wrote:

Suppose I have some data in filtered columns which are labeled except one
column 'salary'. My question is:

Is it possible to hide the entire row(s) of 'salary' column one by one
automatically on entering data in cell(s).

There must be a way to accomplish this via vba but I am novice in writing
code.

Your help is requested.

Regards.