Hiding Rows that contain Blanks

jjm3066

New Member
Joined
Jun 22, 2011
Messages
43
Hi,

I have a sheet that has columns A:CJ and over 2,000 rows. Columns A-E contain data throughout the 2,000 rows. I want to create a macro, that hides any row that contains blank data from F:CJ.

This is what I have so far and its still hiding rows that contain data:

Sub hideblankrowsincol()
Dim myRg As Range

Set myRg = Range([F4:CJ4].End(xlDown), [A65536:CJ65536].End(xlUp))
On Error Resume Next
Set myRg = myRg.SpecialCells(4)
If Err = 0 Then
myRg.EntireRow.Hidden = True
Else
MsgBox "No blanks"
End If
Set myRg = Nothing
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try

Code:
Sub DelBlanks()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = 1 To LR
    Rows(i).Hidden = WorksheetFunction.CountA(Range("F" & i).Resize(, 83)) = 0
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thank you very much that worked perfect!

One other request: I have a book that lets say contains 2,000 lines. Column B and C are an account and then a product, what concantenate to make Column A. Account: Product. This makes up 14 lines of one account and 14 products. I need to add 7 more blank lines after each account ends to add 7 more products. Is there a way to say after each 14th line, add 7 blank rows?
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,476
Members
452,915
Latest member
hannnahheileen

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