Rows.Hidden statement issue

danners430

New Member
Joined
Aug 3, 2017
Messages
45
Hi Guys,

This issue has stumped even the best programmer I know, neither of us can see what the problem is. As far as we're concerned this code should work like a charm...

The code is designed to run upon the clicking of a checkbox. When it is ticked, any rows that have "1" in column 8 will be hidden. However, since I altered a completely unrelated piece of code (explained below), the code has broken.

Code:
Sub HideCompleted()                             'Runs on Checkbox_Click event                                                '
Application.Cursor = xlWait                     'Will check if checkbox is ticked
                                                '
If CheckBox1.Value = True Then                  'If true: hide all completed rows and run TableFill for uncompleted
Sheet1.Unprotect                                'rows only.
For i = 3 To 1000                               '
                                                'If false: show all rows and run TableFill for all rows
    If Cells(i, 8) = 1 Then
    Sheet1.Rows(i).EntireRow.Hidden = True      'Error on this line: Application or Object Defined Error
        
    End If


Next i


i2 = 1


For i = 3 To 1000


    If Rows(i).Hidden = False And Cells(i, 2) <> "" Then
    TableRow = "B" & i & ":K" & i
    If i2 Mod 2 = 0 Then Range(TableRow).Interior.Color = RGB(205, 225, 255) Else: Range(TableRow).Interior.ColorIndex = 0
    i2 = i2 + 1
    End If


Next i

There is similar code after this that reverses the process, but I've excluded it to save space. It has the exact same problem.

i = Public Integer
i2 = Dim Integer
TableRow = Dim String

The changes that I made to the spreadsheet that seemingly have rendered the code useless are as follows:

Within the userform that fills out the spreadsheet, a combobox was repaced with a listbox to allow multiple selections. To support this, the variables that the combobox fed into were replaced with arrays, and the relevant cells filled out by constructing strings from the arrays. However, this didn't affect any of the cells that this procedure feeds off. The only other change was that i became a public variable, instead of being declared within the module.

Anyone got any suggestions?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
As said in the code, the error is on the Rows(i).Hidden = True line, line 8. Unfortunately I can't post all the code, as the document is restricted :(
 
Upvote 0
You might look at whether changes you made involve other cells in the same rows. It may be necessary to force that code to release any leftover range selections that might conflict with your rows.hidden ranges. Good luck figuring this out!
 
Upvote 0
Hey guys, problem solved after much toing and froing...
Problem was a radio button in the last column not being set to move & resize with cells - everything else worked fine apparently... wierd...
Now I just need to find a way to set that property programmatically, as they're created automatically as part of a procedure. Does anyone have any ideas on that count?!

Many thanks for the help anyway!
 
Upvote 0

Forum statistics

Threads
1,216,200
Messages
6,129,475
Members
449,511
Latest member
OttosArmy

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