Code worked...Then now doesn't (without any changes i can think of)

jimayers

Board Regular
Joined
Nov 14, 2010
Messages
99
I have a code that worked for years, but all of a sudden it does NOT. Not even the backups that I save. This leads me to believe it is something on my machine or an Excel update I'm unfamiliar with. BUT, it is a hufe pain and I can't figure it out. The code populates a listbox. (I have another code that is doing the same thing...aagghh!)

This is the bit of code the debugger catches up on with an "Application-defined or Objdect-defined" error
Code:
    .Rows.Hidden = False

This is the code it is emmbedded in:
Code:
Sub Populating_ListBox_withExtractedDATA_2()
Application.ScreenUpdating = False
Dim r, LastRow As Long
Dim Cname, Ccode As String
Dim i As Integer
With ThisWorkbook.Worksheets("SOMs")
    .Rows.Hidden = False
    .Columns.Hidden = False
    .ListBox1.Clear 'clear all existing list box items
    
    LastRow = Cells(Rows.count, 1).End(xlUp).Row
    Rows(1 & ":" & LastRow).Hidden = False
    
    i = 0
        For r = 1 To LastRow
            If Cells(r, 3).Value = Cname Then GoTo a
            If Cells(r, 1) = "COURSE TITLE:" Then
                Cname = Cells(r, 3)
                Ccode = Mid(Trim(Cells(r, 3).Offset(4, 14)), 1, 3)
                ColumnCount = 2
                .ListBox1.AddItem
                    .ListBox1.List(i, 0) = Cname
                    .ListBox1.List(i, 1) = Ccode
                i = i + 1
            End If
a:
        Next r
End With
Application.ScreenUpdating = True
End Sub
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Is your sheet still named "SOMs"? You're missing a bunch of periods ie.
Code:
LastRow = .Cells(.Rows.count, 1).End(xlUp).Row
    .Rows(1 & ":" & LastRow).Hidden = False
    
    i = 0
        For r = 1 To LastRow
            If .Cells(r, 3).Value = Cname Then GoTo a
'etc. etc.
HTH. Dave
 
Upvote 0
Yes, the sheet is still labeled "SOMs"
I didn't think I needed the periods as I thought it identified with the active sheet
 
Upvote 0
You have the code that needs periods surrounded by a "With" statement. So it likely does refer to the active sheet which may or may not be the sheet the "With" refers to. Which is what I was getting at, the active sheet could be any sheet and may lead to problems. I'm guessing that's not causing your error however. Trial commenting out the "Application.ScreenUpdating = False" line of code. HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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