Hide Row if Cells in Column C contain

Triarii26

New Member
Joined
Jun 9, 2015
Messages
8
Hi all,

thanks for taking a look at my problem.

I need a formula in VBA Which searches the values in column C for "10000" only.
Upon finding the values, it hides the row.
The length of the list is dynamic so hopefully this could also be factored in.

I've had a google search and I could find ways to delete the rows, but not hide: that code also used a loop between the top and bottom rows, and for whatever reason once it was completed, the conditional formatting would not update, and there would be colour coding that carried on much longer than the list (as some of the list was deleted), and the remaining rows in the list were incorrectly coloured. I have no idea why that would happen so if anyone could enlighten my novice self to that then that would be appreciated also.

Thanks!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hello,

does this work as expected?

Code:
Sub HIDE()
    Application.ScreenUpdating = False
    For MY_ROWS = 2 To Range("C" & Rows.Count).End(xlUp).Row
        If Range("C" & MY_ROWS).Value = 10000 Then
            Rows(MY_ROWS).Hidden = True
        End If
    Next MY_ROWS
    Application.ScreenUpdating = True
End Sub

Could you just not use Autofilter?
 
Upvote 0
This is perfect, thanks!

problem solved.

When I use a recorded autofilter the problem is that a s the sheet uses values up to the limit which can be anywhere between 0 and 10,000, when I recorded a macro for the autofilter it says criteria = XXXX, the X's donating all the numbers that are shown. The list changes daily so using a filter would mean that the macro recorded wouldn't work (as all those X's would be different, or I'd have to put in numbers 0-10,000 in). That's what appeared to happen anyway.

Thanks for your help!
 
Upvote 0
Story to resurrect the post, but if I want to base the find on a value of another cell, in this case, J1, not 10000 and this value varies depending upon an input box, how would I do this?
I have tried to change it to value = "=$J$1", or the formula variant. I know it's something simple that I'm missing.
thanks.
 
Upvote 0
Hello,

change

Code:
If Range("C" & MY_ROWS).Value = 10000 Then

to

Code:
If Range("C" & MY_ROWS).Value = range("J1").value Then
 
Upvote 0

Forum statistics

Threads
1,207,091
Messages
6,076,522
Members
446,212
Latest member
KJAYPAL200

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