Hide Rows without a value

riedyp

Board Regular
Joined
Feb 13, 2020
Messages
88
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to write a code that:
Looks at cells in column A from rows 9:100
-If a cell does not have an integer then that cells entire row is to be hidden.
This is what I have so far. Thank you.

VBA Code:
Private Sub CommandButton7_Click() '''''''''''''''''''''' Question Rollup
Dim x As Variant
For x = 9 To 100
If Cells(X,1)="" Then
Cells(X,1).hidden =true
Next X
End Sub
 

Attachments

  • numbers.PNG
    numbers.PNG
    34.4 KB · Views: 8

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
How about

VBA Code:
Private Sub CommandButton7_Click()
  Dim x As Variant
  Application.ScreenUpdating = False
  For x = 9 To 100
    If Cells(x, 1) = "" Then
      Rows(x).Hidden = True
    End If
  Next x
End Sub
 
Upvote 0
How about just
VBA Code:
Range("A8:A100").AutoFilter 1, "<>", , , 0
 
Upvote 0
That works but then this other code i have no longer works to undo those hidden rows.
Is there a reverse for the code you sent me?
Range("A8:A100").AutoFilter 1, "<>", , , 0



VBA Code:
Private Sub CommandButton5_Click() ''''''''''''''''''''' Enter Editing Mode
Dim myGB As GroupBox    'Hide All Group Boxes
For Each myGB In ActiveSheet.GroupBoxes
myGB.Visible = True
Next myGB

Dim myOB As OptionButton            'Show All Option Buttons
For Each myOB In ActiveSheet.OptionButtons
    myOB.Visible = msoTrue
Next myOB

Rows("9:100").Hidden = False
End Sub
 
Upvote 0
Yes, you can use
VBA Code:
Range("A8:A100").AutoFilter
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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