column width VBA question
Thank You JP. I fixed my first problem. I used one line of code
Range("C:C,A:A").ColumnWidth = 4.57
And it works. Thanks
As for 2nd issue. I know I used Protect() as one of the names in my sheet
but I deleted it. And the code compiles but it does not protect me sheet with
a password. I can just go and unprotect it without being prompt for pass.
Any ideas?
"JP" wrote:
I ran your ColumnWidth code and didn't experience the same issue. Try
stepping through the code or setting the column width of each column
individually. FYI, there's no need to select the column first before
setting the ColumnWidth property.
Regarding your second issue, that would happen if you have a variable
called "protect" somewhere in your code. If you give a variable the
same name as a property, VBA will adjust the case of the property to
match. It doesn't affect the method however, and I wasn't able to
duplicate the issue.
--JP
On Sep 25, 12:10 pm, Damian wrote:
I have this code:
Range("C:C,A:A").Select
Selection.ColumnWidth = 4.57
EnableSelection = Excel.XlEnableSelection.xlNoSelection
BUT it changes the with of columns A, B and C. I want B to be left alone.
What am I doing wrong. Also will the last line of code work if I dont want
anything to be selected?
Another question that I posted already but its on 2 page now and I dont
think it will get answared.
In this code:
With ActiveSheet
.protect Password:="eli"
.EnableSelection = xlUnlockedCells
.protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True
End With
I cant get the "p" in .protect to be capital "P". Everythine I change it it
changes right back and the code dont work.
Thank you
|