Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the two pieces of code below in my spreadsheet. When I run the
Engineering macro I get a run time error 1004 with the message "Unable to set the Hidden Property of the range Class for the following line. Range("Long_Lease").EntireRow.Hidden = False This was working fine until I added the worksheet change code to autofit the columns and still works if I remove the reprotection line of this part of code Is there a way I can overcome this? Private Sub Worksheet_Change(ByVal Target As Range) Let HiddenCells = Range("AV3") Activesheet.Unprotect Password:=HiddenCells Me.Application.ActiveWorkbook.RefreshAll Target.EntireColumn.AutoFit On Error Resume Next Target.Dependents.EntireColumn.AutoFit Activesheet.Protect Password:=HiddenCells, DrawingObjects:=True, Contents:=True, Scenarios:=True End Sub Sub Engineering() Dim P1 As Worksheet Set WS = ThisWorkbook.Activesheet Dim C As Long For C = 65535 To 65 Step -1 Let HiddenCells = Range("AV3") Activesheet.Unprotect Password:=HiddenCells If WS.Cells(C, 1).Value = "E" Then WS.Cells(C + 1, 1).EntireRow.Insert Range("Engineering").Select Range("Engineering").EntireRow.Hidden = False Selection.Copy WS.Cells(C + 1, 1).Activate Activesheet.Paste Range("Engineering").Select Range("Engineering").EntireRow.Hidden = True WS.Cells(C + 1, 1).Activate Activesheet.Protect Password:=HiddenCells, DrawingObjects:=True, Contents:=True, Scenarios:=True Exit Sub End If Next C End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
OnTime code error "can't execute code in break mode" | Excel Programming | |||
Error in Excel VBA Code (Error 91) | Excel Programming | |||
How can I still go to the error-code after a On Error Goto? | Excel Programming | |||
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) | Excel Programming |