Worksheet_Activate Event to Hide the Blank Data Rows with VBA Macro
Worksheet_Activate is one of the Worksheet Event , this Event occurs when the Worksheet get activated and then Macro code will Execute.
The following macro will Hide the Data Rows whose Data in C column range is either '0' or blank as given in below example.
Private Sub Worksheet_Activate()
Dim WB As Workbook
Dim WS As Worksheet
Dim X As Integer
Set WB = ThisWorkbook
Set WS = WB.Worksheets(ActiveSheet.Name)
WS.Rows("1:20").Hidden = False
For X = 1 To 20
MyVal = WS.Range("C" & X).Value
If MyVal = 0 Or MyVal = "" Then WS.Rows(X).Hidden = True
Next X
End Sub
Example :
Worksheet_Activate is one of the Worksheet Event , this Event occurs when the Worksheet get activated and then Macro code will Execute.
The following macro will Hide the Data Rows whose Data in C column range is either '0' or blank as given in below example.
Private Sub Worksheet_Activate()
Dim WB As Workbook
Dim WS As Worksheet
Dim X As Integer
Set WB = ThisWorkbook
Set WS = WB.Worksheets(ActiveSheet.Name)
WS.Rows("1:20").Hidden = False
For X = 1 To 20
MyVal = WS.Range("C" & X).Value
If MyVal = 0 Or MyVal = "" Then WS.Rows(X).Hidden = True
Next X
End Sub
Data before Event Occur :
--------------------------------------------------------------------------------------------------------
Thanks, TAMATAM ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------
Thanks, TAMATAM ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------
No comments:
Post a Comment
Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.