Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 71
Default column width VBA question

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 897
Default column width VBA question

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default column width VBA question

#1. Do you have merged cells in that range (column A to C) that include column
B???

If you do, try:
Range("C:C,A:A").ColumnWidth = 4.57

It worked ok in xl2003, but each version of excel seems to treat merged cells
better than the last.

=======

The upper/lower case in .protect won't break your code. It may be irritating,
but it's not a problem.

You can fix the uppercase irritation by typing this line anywhere in your code:
Dim Protect
Then hit enter
Then delete that line.

I'm not sure what your problem is. It could be as simple as that password not
being correct (uppercase ELI???).

Or it could be what caused the .protect to become lower case.

Do you have a subroutine called Protect or a function called Protect or anything
else in your code called Protect?

If it's a subroutine, try naming it:

Sub myProtect(...)

or something that doesn't fight with the stuff built into VBA.


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


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 71
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 71
Default column width VBA question

I do have merge cells. Thank you.
DIM Protect - worked for the uppercase. Thank you again.

BUT unfortunately that did not solve my problem. the password is "eli" when
i ran my micro it unprotects it and protects it again very nicely, BUT i can
also go to tools and unprotect and it will not prompt me for the password.
How come?

Thanks for all the help

"Dave Peterson" wrote:

#1. Do you have merged cells in that range (column A to C) that include column
B???

If you do, try:
Range("C:C,A:A").ColumnWidth = 4.57

It worked ok in xl2003, but each version of excel seems to treat merged cells
better than the last.

=======

The upper/lower case in .protect won't break your code. It may be irritating,
but it's not a problem.

You can fix the uppercase irritation by typing this line anywhere in your code:
Dim Protect
Then hit enter
Then delete that line.

I'm not sure what your problem is. It could be as simple as that password not
being correct (uppercase ELI???).

Or it could be what caused the .protect to become lower case.

Do you have a subroutine called Protect or a function called Protect or anything
else in your code called Protect?

If it's a subroutine, try naming it:

Sub myProtect(...)

or something that doesn't fight with the stuff built into VBA.


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


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default column width VBA question

Damian

I revised the code in the other thread/other news group and explained why.


Gord

On Fri, 25 Sep 2009 09:54:02 -0700, Damian
wrote:

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



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default column width VBA question

If you don't get prompted for a password when you do it manually, then you don't
have a password.

But I'm not sure why you're using two .protect's he

With ActiveSheet
.protect Password:="eli"
.EnableSelection = xlUnlockedCells
.protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True
End With


did you mean .Unprotect in the first instance?

or maybe...

With ActiveSheet

.unprotect password:="eli"
.EnableSelection = xlUnlockedCells
.protect password:="eli", _

DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True
End With


Damian wrote:

I do have merge cells. Thank you.
DIM Protect - worked for the uppercase. Thank you again.

BUT unfortunately that did not solve my problem. the password is "eli" when
i ran my micro it unprotects it and protects it again very nicely, BUT i can
also go to tools and unprotect and it will not prompt me for the password.
How come?

Thanks for all the help

"Dave Peterson" wrote:

#1. Do you have merged cells in that range (column A to C) that include column
B???

If you do, try:
Range("C:C,A:A").ColumnWidth = 4.57

It worked ok in xl2003, but each version of excel seems to treat merged cells
better than the last.

=======

The upper/lower case in .protect won't break your code. It may be irritating,
but it's not a problem.

You can fix the uppercase irritation by typing this line anywhere in your code:
Dim Protect
Then hit enter
Then delete that line.

I'm not sure what your problem is. It could be as simple as that password not
being correct (uppercase ELI???).

Or it could be what caused the .protect to become lower case.

Do you have a subroutine called Protect or a function called Protect or anything
else in your code called Protect?

If it's a subroutine, try naming it:

Sub myProtect(...)

or something that doesn't fight with the stuff built into VBA.


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


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 71
Default column width VBA question

YES! Thank you so much.

It was the double .Protect that was messing things up.

"Dave Peterson" wrote:

If you don't get prompted for a password when you do it manually, then you don't
have a password.

But I'm not sure why you're using two .protect's he

With ActiveSheet
.protect Password:="eli"
.EnableSelection = xlUnlockedCells
.protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True
End With


did you mean .Unprotect in the first instance?

or maybe...

With ActiveSheet

.unprotect password:="eli"
.EnableSelection = xlUnlockedCells
.protect password:="eli", _

DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingRows:=True
End With


Damian wrote:

I do have merge cells. Thank you.
DIM Protect - worked for the uppercase. Thank you again.

BUT unfortunately that did not solve my problem. the password is "eli" when
i ran my micro it unprotects it and protects it again very nicely, BUT i can
also go to tools and unprotect and it will not prompt me for the password.
How come?

Thanks for all the help

"Dave Peterson" wrote:

#1. Do you have merged cells in that range (column A to C) that include column
B???

If you do, try:
Range("C:C,A:A").ColumnWidth = 4.57

It worked ok in xl2003, but each version of excel seems to treat merged cells
better than the last.

=======

The upper/lower case in .protect won't break your code. It may be irritating,
but it's not a problem.

You can fix the uppercase irritation by typing this line anywhere in your code:
Dim Protect
Then hit enter
Then delete that line.

I'm not sure what your problem is. It could be as simple as that password not
being correct (uppercase ELI???).

Or it could be what caused the .protect to become lower case.

Do you have a subroutine called Protect or a function called Protect or anything
else in your code called Protect?

If it's a subroutine, try naming it:

Sub myProtect(...)

or something that doesn't fight with the stuff built into VBA.


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

--

Dave Peterson


--

Dave Peterson

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
Change Cell Width WITHOUT changing Column width dww701 Excel Discussion (Misc queries) 1 January 12th 09 10:52 PM
Column Width Template Question metaltecks Excel Discussion (Misc queries) 3 August 24th 07 10:58 PM
how do I create multiple column width in the same column in excel Vish Excel Discussion (Misc queries) 9 November 3rd 06 11:49 PM
How to make cell width different than the column width it lies in John Excel Discussion (Misc queries) 2 September 11th 06 10:41 PM
Change the width of a single column in a column chart Dave Charts and Charting in Excel 2 December 13th 04 07:25 PM


All times are GMT +1. The time now is 06:08 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"