Hide & unhide rows within range when double click cell

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
Hello
I search for way to hide & unhide rows within range at once based on double click cell in A20 if range B;F is empty
so if I double click cell in A20 then will hide rows after row 20 except TOTAL row and empty range(B:F)
example:
فاتورة.xlsm
ABCDEFG
20ITEMBRANDTYPEORIGINQTYPRICETOTAL
211BS 1200R20G580JAP11.0012.00132.00
2220.00
230.00
240.00
250.00
260.00
270.00
280.00
290.00
300.00
310.00
320.00
330.00
340.00
350.00
360.00
370.00
380.00
390.00
400.00
410.00
420.00
430.00
440.00
450.00
460.00
47TOTAL132.00
فاتورة
Cell Formulas
RangeFormula
G21:G46G21=E21*F21
G47G47=SUM(G21:G46)
Cells with Data Validation
CellAllowCriteria
B26ListBS 1200R20;BS 700R16;BS 315/80R22.5;BS 315/80RR.5;BS 225/55R16;BS 205/70R15C;BS 215/70R15C;FR 215/75R15;BS 255/70R15C ;GO 315/80R22.5;TQ 195/65R15;KB 215/70R15C;WS 285/70R19.5;GO 1200R20;FU 265/75R16;VAR 70A;AUTO 68A;XPRO 70A;XPRO 60A;Q8 10W-40;LIQ 10W-40
B21:B22ListBS 1200R20;BS 700R16;BS 315/80R22.5;BS 315/80RR.5;BS 225/55R16;BS 205/70R15C;BS 215/70R15C;FR 215/75R15;BS 255/70R15C ;GO 315/80R22.5;TQ 195/65R15;KB 215/70R15C;WS 285/70R19.5;GO 1200R20;FU 265/75R16;VAR 70A;AUTO 68A;XPRO 70A;XPRO 60A;Q8 10W-40;LIQ 10W-40
C21ListG580;R187
D21ListJAP


when double click in cell A20 then should be
in.xlsm
ABCDEFG
20ITEMBRANDTYPEORIGINQTYPRICETOTAL
211BS 1200R20G580JAP11.0012.00132.00
47TOTAL132.00
v
Cell Formulas
RangeFormula
G21G21=E21*F21
G47G47=SUM(G21:G46)
Cells with Data Validation
CellAllowCriteria
B21:B22ListBS 1200R20;BS 700R16;BS 315/80R22.5;BS 315/80RR.5;BS 225/55R16;BS 205/70R15C;BS 215/70R15C;FR 215/75R15;BS 255/70R15C ;GO 315/80R22.5;TQ 195/65R15;KB 215/70R15C;WS 285/70R19.5;GO 1200R20;FU 265/75R16;VAR 70A;AUTO 68A;XPRO 70A;XPRO 60A;Q8 10W-40;LIQ 10W-40
C21ListG580;R187
D21ListJAP




and if I want to return showing rows when double click in A20 again
then should be
in.xlsm
ABCDEFG
20ITEMBRANDTYPEORIGINQTYPRICETOTAL
211BS 1200R20G580JAP11.0012.00132.00
2220.00
230.00
240.00
250.00
260.00
270.00
280.00
290.00
300.00
310.00
320.00
330.00
340.00
350.00
360.00
370.00
380.00
390.00
400.00
410.00
420.00
430.00
440.00
450.00
460.00
47TOTAL132.00
v
Cell Formulas
RangeFormula
G21:G46G21=E21*F21
G47G47=SUM(G21:G46)
Cells with Data Validation
CellAllowCriteria
B26ListBS 1200R20;BS 700R16;BS 315/80R22.5;BS 315/80RR.5;BS 225/55R16;BS 205/70R15C;BS 215/70R15C;FR 215/75R15;BS 255/70R15C ;GO 315/80R22.5;TQ 195/65R15;KB 215/70R15C;WS 285/70R19.5;GO 1200R20;FU 265/75R16;VAR 70A;AUTO 68A;XPRO 70A;XPRO 60A;Q8 10W-40;LIQ 10W-40
B21:B22ListBS 1200R20;BS 700R16;BS 315/80R22.5;BS 315/80RR.5;BS 225/55R16;BS 205/70R15C;BS 215/70R15C;FR 215/75R15;BS 255/70R15C ;GO 315/80R22.5;TQ 195/65R15;KB 215/70R15C;WS 285/70R19.5;GO 1200R20;FU 265/75R16;VAR 70A;AUTO 68A;XPRO 70A;XPRO 60A;Q8 10W-40;LIQ 10W-40
C21ListG580;R187
D21ListJAP

thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi Abdo, try the following on a copy of your workbook:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("A20")) Is Nothing Then
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        Cancel = True
        Dim c As Range
        For Each c In Range("B21:B" & Cells(Rows.Count, "A").End(xlUp).Row - 1)
            If c.EntireRow.Hidden = True Then
                c.EntireRow.Hidden = False
            Else
                If c = "" Then
                    c.EntireRow.Hidden = True
                End If
            End If
        Next c
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End If
End Sub
 
Upvote 1
Solution
Hello Abdo:

Here is another code for you to consider:

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  If Target.Address(0, 0) <> "A20" Then Exit Sub
  Cancel = True
  Dim r As Range
  For Each r In Range("B21", Range("A:A").Find("TOTAL", , xlValues, xlWhole, xlByRows, xlPrevious, False).Offset(-1, 1))
    Rows(r.Row).Hidden = (Rows(r.Row).Hidden = False) * (r & r.Offset(, 1) & r.Offset(, 2) & r.Offset(, 3) & r.Offset(, 4) = "") 'range(B:F)
  Next
End Sub

--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
 
Upvote 0
Try


VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  If Target.Address(0, 0) <> "A20" Then Exit Sub
Application.ScreenUpdating = False
  Cancel = True
  Dim r As Range
  For Each r In Range("B21", Range("A:A").Find("TOTAL", , xlValues, xlWhole, xlByRows, xlPrevious, False).Offset(-1, 1))
    Rows(r.Row).Hidden = (Rows(r.Row).Hidden = False) * (r & r.Offset(, 1) & r.Offset(, 2) & r.Offset(, 3) & r.Offset(, 4) = "") 'range(B:F)
  Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,305
Members
449,150
Latest member
NyDarR

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top