Commenting out code

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hi All
(I know very little about VBA)
I commented out code as you can see below but the code is still working. I closed Excel and reopened with no change. I only have 1 workbook open and I know I'm looking at the right code. The code I'm referring to is below the commented 'Hide Rows--------------------
When I make a change in G2, the rows are being hidden despite the commented code. I know this can't be possible but I can't think of why this is happening.


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect "********" '(Auto unlock sheet)

'(Calculates sheet when changes are made within the range)
Worksheets("Rack").Calculate
Range("bm:bm").AutoFilter 1, "<>0"
Application.Calculation = xlCalculationManual
    For Each Cll In Range("A1:A1300,F1:F1300,G1:G1300,I1:I1300,K1:K1300,L1:L1300,M1:M1300")
        For Each TCll In Target
       If Cll.Address = TCll.Address Then
            ThisWorkbook.Sheets("Multi Build").Calculate
            ThisWorkbook.Sheets("Rack").Calculate
            'ActiveSheet.Protect "********"  '(Auto locks sheet)
            Exit Sub
        End If
        Next TCll
   Next Cll
'Hide rows---------------------------------------------------------------
'ActiveSheet.Unprotect "********"
If Not Intersect(Target, Range("G2")) Is Nothing Then '(Rack#1x24)
        If Target.Count = 1 Then
            'If Range("BK3").Value = "2" Then
               ' Rows("30:53").EntireRow.Hidden = True
            'ElseIf Range("BK3").Value <> "3" Then
                'Rows("6:53").EntireRow.Hidden = False
            'End If
        End If
    End If
If Not Intersect(Target, Range("G2")) Is Nothing Then '(Rack#1x12)
        If Target.Count = 1 Then
           'If Range("BK3").Value = "1" Then
               ' Rows("18:53").EntireRow.Hidden = True
            'End If
        End If
    End If
  ' ActiveSheet.Protect "********"
End Sub
 
Last edited by a moderator:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I tested your code as is and it works as expected, the commented code does not run regardless if changing G2 or any other cell.

Might be worth reinstalling and see if it fixes it
 
Upvote 0
Thank you MARK858 - I see the light :sneaky:

It looks like this may be the line actually causing the rows to be hidden or "Filtered" as Mark is alluding to

VBA Code:
Range("bm:bm").AutoFilter 1, "<>0"
 
Upvote 0
As a test to confirm you could go into the VBA editor and step through your code and watch the sheet, assuming this line is causing it you should see the lines "hidden" once you step through this line (F8 = step through)
 
Upvote 0
It was the autofilter. Now I just have to figure out why I had that put there. This has been years in the making. I have recently learned to put in comments for this reason.
Thank you guys! This was driving me crazy
 
Upvote 0
Happy that you worked out what was causing your issue.
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

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