If you want to hide a row, when the cell value matches any criteria.For Example you have names in col A and you want to hide entire row if cell value is "j".Snapshot Below-
Here is the code-
Example 1:
Sub hide_rows_with_matching_values()
Dim i As Long
For i = Sheets(1).Range("a65356").End(xlUp).Row To 1 Step -1
' it will hide all the rows when name is equal to "J"
' we have taken "1" in Cells(i, 1 ) below because we r looking in row 1
If Sheets(1).Cells(i, 1).Value = "j" Then
Sheets(1).Cells(i, 1).EntireRow.Hidden = True
End If
Next
End Sub
Example 2:
Sub hide_rows_with_greater_than_some_value()
Dim i As Long
For i = Sheets(1).Range("a65356").End(xlUp).Row To 1 Step -1
' it will hide all the rows when value in col b > 30
' we have taken "2" in Cells(i, 2 ) below because we r looking in row 2
If IsNumeric(Sheets(1).Cells(i, 2).Value) And Sheets(1).Cells(i, 2).Value > 30 Then
Sheets(1).Cells(i, 2).EntireRow.Hidden = True
End If
Next
End Sub
Subscribe to:
Post Comments (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
If you want to add a new menu on mouse right click "Workbook Navigation showing you the list of all open workbooks and worksheets in ea...
-
Macro to Export Range in Json Format Option Explicit Sub export_in_json_format() Dim fs As Object Dim jsonfile Dim rangetoex...
No comments:
Post a Comment