Help with making code for efficient

Sean15

Well-known Member
Joined
Jun 25, 2005
Messages
698
Office Version
  1. 2010
Platform
  1. Windows
Hi:

I adapted codes below from old online codes. Code is supposed to hide all blank rows after last row of data in Column C (well, that’s my intent). The code runs very slow. Also, after executing code, there are two blank rows after the last row of data. Blank rows should be hidden after the code executes. Could someone fix code to?

Make it run faster
Hide all blank rows after last row of data in column C.

VBA Code:
Sub HideRowCellTextValue()

Rows.EntireRow.Hidden = False

Application.ScreenUpdating = False

StartRow = 12

LastRow = 1233

iCol = 3

For i = StartRow To LastRow

If Cells(i, iCol).Value <> "" Then

Cells(i, iCol).EntireRow.Hidden = False

Else

Cells(i, iCol).EntireRow.Hidden = True

End If

Next i

Application.ScreenUpdating = True

End Sub



Thank you for your help.
 
Last edited by a moderator:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Something else is going on with your code. I ran the macro here and it completed in less than one second.
 
Upvote 0
@Sean15 in future please do not mark a post as the solution when it does not contain one. Thanks
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,063
Members
449,090
Latest member
fragment

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