Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default userinterfaceonly=True fails with this code!

Hi All,

I have a workbook in which all the sheets are protected with the code
posted below. Other code within the workbook works with the the sheets
protected but the second code snippet below fails at the copy /paste
lines. Can anybody point me in the right direction as to what is
causing this ?

I have completely unprotected all the sheets then re-protected them
with the code, re-saved the workbook etc shown but nothing l have
tried cures this problem and it is driving me insane. I have recently
added 'Option Private Module' to each of the code modules to prevent
users seeing the code from within Excel but removing same does not
cure the problem.

All contributions gratefully received.

Sub MyProtect()

Dim Filename As String

Filename = ActiveWorkbook.Name

Application.ScreenUpdating = False

For Each Sht1 In Workbooks(Filename).Worksheets
Sht1.DisplayAutomaticPageBreaks = False
Sht1.Protect ("PWD"), userinterfaceonly:=True
Sht1.EnableOutlining = True
Next Sht1

End Sub

Sub ImportedSwitchDatabase_To_SwitchDatabase()

Dim CheckArray As Range
Dim FindWhat As String
Dim SourceRow As Long
Dim TargetRow As Long
Dim SourceSheet As Worksheet
Dim TargetSheet_1 As Worksheet
Dim TargetSheet_2 As Worksheet
Dim CheckSheet As Worksheet

'Change these 4 lines to the relevant sheets

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''
Set SourceSheet = Sheets("Imported_Switch_Database")
Set CheckSheet = Sheets("Switch_Database")
Set TargetSheet_1 = Sheets("Switch_Database")
Set TargetSheet_2 = Sheets("Ignored_Switch_Database")

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''

SourceSheet.Activate
For Each sCell In SourceSheet.Range("D7:D" & LR)
Set CheckArray = CheckSheet.Range("D7:D" & LRo(, CheckSheet,
"B"))
FindWhat = sCell.Value
SourceRow = sCell.Row
If CheckArray.Find(FindWhat, lookat:=xlWhole,
searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True) Is
Nothing Then
TargetRow = LRo(, TargetSheet_1, "B") + 1
If TargetRow 6 Then
SourceSheet.Range("B" & SourceRow & ":CL" &
SourceRow).Copy TargetSheet_1.Range("B" & TargetRow)
End If
Else
TargetRow = LRo(, TargetSheet_2, "B") + 1
If TargetRow 6 Then
SourceSheet.Range("B" & SourceRow & ":CL" &
SourceRow).Copy TargetSheet_2.Range("B" & TargetRow)
End If
End If
Next

'Tidy up
SourceSheet.Activate
With ActiveSheet.Range("B7:CL" & LR)
.RowHeight = 57.5
.VerticalAlignment = xlTop
End With
TargetSheet_1.Activate
With ActiveSheet.Range("B7:CL" & LR)
.RowHeight = 57.5
.VerticalAlignment = xlTop
End With
TargetSheet_2.Activate
With ActiveSheet.Range("B7:CL" & LR)
.RowHeight = 57.5
.VerticalAlignment = xlTop
End With

End Sub

Note: LRo is a UDF to find the last row on a specific sheet, col, etc
and returns the correct result

Regards

Michael
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default userinterfaceonly=True fails with this code!

Hi All,

Problem solved, but not sure l understand why:

Dim SourceSheet As Worksheet

but

Set SourceSheet = Sheets("MySheet")

should be

Set SourceSheet = Worksheets("MySheet")

Regards

Michael

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with UnProtect userinterfaceonly:=true robs3131 Excel Programming 2 April 23rd 08 02:18 PM
".Protect userinterfaceonly:=True" & ".EnableSelection = xlUnlockedCells" not tabing STEVE BELL Excel Programming 1 February 23rd 06 01:39 AM
question about worksheet protection using userinterfaceonly:=true David Brisco Excel Programming 0 February 9th 04 09:25 PM
ActiveSheet.Protect UserinterfaceOnly:=true Tim[_14_] Excel Programming 4 August 7th 03 09:06 PM
Problem with using Protect when userinterfaceonly:=True Les[_4_] Excel Programming 2 July 18th 03 01:50 PM


All times are GMT +1. The time now is 06:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"