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.
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?
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?