![]() |
Cell click
Hello
I would like to be able to click on cell A25 and hide any rows in 26-44 that have an 1 in Col A. I can use this code to hide the rows using a button, but I am not sure how to incorporate the click event to fire the mcaro. My code : rivate Sub CommandButton1_Click() Application.ScreenUpdating = False Dim I As Long Dim Hidden As Boolean For I = 26 To 44 If Rows(I).EntireRow.Hidden Then Hidden = True Rows(I).EntireRow.Hidden = False End If Next I If Hidden Then Exit Sub For I = 26 To 44 Step 1 If Cells(I, 1).Value = 1 Then Range(Cells(I, 1), Cells(I, 1)).EntireRow.Hidden = True End If Next I End Sub Thanks for your help |
Cell click
Is this what you want
Private Sub CommandButton1_Click() Application.ScreenUpdating = False For I = 26 To 44 Rows(I).EntireRow.Hidden = Not Rows(I).EntireRow.Hidden Next I Application.ScreenUpdating = True End Sub and put it in the worksheet code module for that worksheet code module, not a standard code module. To do this, right-click on the sheet tab, select the View Code option from the menu, and paste the code in. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Sandy" wrote in message ... Hello I would like to be able to click on cell A25 and hide any rows in 26-44 that have an 1 in Col A. I can use this code to hide the rows using a button, but I am not sure how to incorporate the click event to fire the mcaro. My code : rivate Sub CommandButton1_Click() Application.ScreenUpdating = False Dim I As Long Dim Hidden As Boolean For I = 26 To 44 If Rows(I).EntireRow.Hidden Then Hidden = True Rows(I).EntireRow.Hidden = False End If Next I If Hidden Then Exit Sub For I = 26 To 44 Step 1 If Cells(I, 1).Value = 1 Then Range(Cells(I, 1), Cells(I, 1)).EntireRow.Hidden = True End If Next I End Sub Thanks for your help |
Cell click
Not really. When I cick the button it hides all rows that have a 1 in the
first column, leaving those that dont visible, and the next click unhides them. There may be some inefficiency in my code, but it does what I want in the way it hides/unhides. I just need to be able to run the macro via double click on A25. Thanks for your help "Bob Phillips" wrote: Is this what you want Private Sub CommandButton1_Click() Application.ScreenUpdating = False For I = 26 To 44 Rows(I).EntireRow.Hidden = Not Rows(I).EntireRow.Hidden Next I Application.ScreenUpdating = True End Sub and put it in the worksheet code module for that worksheet code module, not a standard code module. To do this, right-click on the sheet tab, select the View Code option from the menu, and paste the code in. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Sandy" wrote in message ... Hello I would like to be able to click on cell A25 and hide any rows in 26-44 that have an 1 in Col A. I can use this code to hide the rows using a button, but I am not sure how to incorporate the click event to fire the mcaro. My code : rivate Sub CommandButton1_Click() Application.ScreenUpdating = False Dim I As Long Dim Hidden As Boolean For I = 26 To 44 If Rows(I).EntireRow.Hidden Then Hidden = True Rows(I).EntireRow.Hidden = False End If Next I If Hidden Then Exit Sub For I = 26 To 44 Step 1 If Cells(I, 1).Value = 1 Then Range(Cells(I, 1), Cells(I, 1)).EntireRow.Hidden = True End If Next I End Sub Thanks for your help |
All times are GMT +1. The time now is 02:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com