last day (15 days later) » 

10:58 PM
0
A: When attempting to apply range properties to a range or cells i get an error

Mathieu GuindonYou don't need a dummy range, just to make sure you don't Union on Nothing. A simple function can ensure that: Private Function Combine(ByVal range1 As Range, ByVal range2 As Range) As Range If Not range1 Is Nothing And Not range2 Is Nothing Then Set Combine = Union(range1, range2) ...

 
sorry I typed that in backwards, What I did was OriginalEntires.select followed by selection.lock
 
Forget Selection exists.
 
Trust me I dont want to use selection. I was just using it as a test.
OriginalEntries.locked = True is throwing 1004 error. I put it on the line right before with. and stepped to it
 
@ForwardEd when you type the . dot operator against an object variable, you get a list of all its members. Selection is Object, which is kind of a wrapper that stands for "just anything that's an object reference". When you type the . dot operator against an Object (or Variant), you get no intellisense/autocompletion dropdown, and the member call can only be resolved at run-time - so it effectively defers errors from compile-time (early bound) to run-time (late bound), and that is why it must be avoided: because implicit late-bound code is bug-prone =)
@ForwardEd make sure the sheet isn't protected. You can't set that property if the sheet is already protected.
 
The sheet is not proctect
I am looking at it now and it shows the press this button to lock so it cant be currently protected.
 
10:59 PM
and it's the same sheet the code was working with?
 
Also first ish line of code unprotects the sheet
 
the code works off ActiveSheet, so, it's pretty frail
 
yes, there are two sheets and its the active one
when I have it do, OriginalEntries.select, the appropriate cells highlight
 
bring up the immediate pane
(ctrl+g)
 
its up
 
11:01 PM
?originalentries.parent.name
is that the sheet you're expecting?
(sorry, do that in break mode)
you know how to use breakpoints?
(hit F9 on a line of code, execution will break there)
 
yeah I have one set at the first END WITH. was getting tired of the for loops
 
and then you can hit F8 to execute the code line by line, and use the immediate pane to output values
yeah break before the instruction that sends everything up in flames though :)
 
was I supposed to type the .parent.name thing in the immediate window?
if so got run time error 438?
 
if it's not in break mode inside the procedure scope, then originalentries has no context, that's why
 
when I add OriginalEntries.parent.Name to the watch, I see it has a value of "Sheet1" which is what I expect
 
11:06 PM
ok good
now ?originalentries.parent.protectionmode
should be false
 
in watch I get false
 
so originalentries.locked = true should work....
 
should....but I get 1004
 
can't repro here, missing something
 
hold on may be a syntax things with me moving things around
nope
 
11:09 PM
what worries me is the ActiveSheet stuff and the implicit references to ActiveSheet
but if originalentries is off the correct sheet and there's no other code, I'm not seeing the problem
 
I can easily change activesheet to worksheets("Sheet1")
 
that would be redundant if "Sheet1" exists in ThisWorkbook at compile-time; best use its CodeName instead
select the sheet module in the Project Explorer (Ctrl+R) and look at its (Name) property (F4)
should be Sheet1
(by default anyway)
that is a programmatic identifier you can use to reliably refer to that specific sheet anywhere in your code
and you can give it a meaningful name
now, everywhere you do Range(...), you'd be doing Sheet1.Range(...) instead
i.e. explicitly qualify all Range member calls. and Cells too
 
gotcha. will change it to sheet1 instead of activesheet
its ok to use WITH SHEET1?
 
Rubberduck can find these implicit ActiveSheet references for you:
@ForwardEd absolutely!
 
I am using rubber duck
 
11:13 PM
NO WAY! :D
that's awesome :)
 
still 1004 on same spot after changing to sheet1 instead of active sheet. and by the code I posted is the entire sub without the sub and end sub
right now my only complaint about rubber duck is manually having to show Code Explorer window every time
 
there's a checkbox in "Window Settings" to have it show up on startup
I find the startup time needs to improve, and the memory consumption causes problems with some very large 32-bit Access projects :(
 
oh damn I hit settings and excel just locked up hard
 
you still in break mode?
 
think so I and I believe the little pop up window is buried under the locked ones
 
11:18 PM
not sure what that means
(that said editing settings in break mode shouldn't be a problem)
 
sometimes those little notice windows with OK, CANCEL etc will pop up underneath the window that is stuck
I can get out of it by hitting esc
killed the break mode , cleared all breaks
hit settings again and everything just freezes until I hit esc...there is no buried window
might be because I am running an older version of duck
 
does it eventually show up?
what version are you on?
 
nop[e
 
Version 2.5.0.5244
OS: Microsoft Windows NT 6.1.7601 Service Pack 1, x64
Host Product: Microsoft Office x64
Host Version: 16.0.12325.20288
Host Executable: EXCEL.EXE
^ not the latest, but works fine here
(yes I'm still on Win7 lol)
 
funny, about exhibits same behaviour as settings!
 
11:23 PM
sounds like WPF UI is taking a toll ...how's your memory going?
 
I just killed AutoCAD and Outlook
5 gig out of 16 being used or 31%
 
hm, if Rubberduck was also loaded in AutoCAD or Outlook, ...
 
I never activated it in either of them
 
2.4.1.5229
rebooted excel and launched duck again and got the numbers on startup
and after restarting excel its still popping up error 1004 at OriginalEntries.Locked = True
Sub Lock_Puzz()

Dim counter_x As Long
Dim counter_y As Long
Dim OriginalEntries As Range

Sheet1.Unprotect ("")

With Sheet1
For counter_y = 3 To 27 Step 3
For counter_x = 1 To 41 Step 5
If .Cells(counter_y, counter_x) <> "" Then
Set OriginalEntries = Combine(OriginalEntries, .Cells(counter_y, counter_x))
End If
Next counter_x
Next counter_y
End With
OriginalEntries.Locked = True
With OriginalEntries
.Locked = True
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
.Color = -52429
 
11:29 PM
ok hold on
 
actually do you mind if I head home? I was supposed to leave the office 1.5 hours ago and I swear my dog is going crossed eyed wanting to be let out. I can pick this back up in about 30 minutes?
 
I gotta run as well :)
 
ok catch you another time. thanks for looking into this
 

last day (15 days later) »