• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Way to Lock Column Widths?

@skidragon


Hi


if your code works fine then it is better to upload the code here because it is helpful to some one if he has same problem or required


Thanks


SP
 
@sgmpatnaik - Here it is:

[pre]
Code:
Sub Column_Widths()

Dim ws As Worksheet
Application.ScreenUpdating = False
For i = 3 To 29
With Sheets(i)
.Columns("A:A").ColumnWidth = 5.57
.Columns("B:B").ColumnWidth = 11.71
.Columns("C:C").ColumnWidth = 8.86
.Columns("D:D").ColumnWidth = 8.86
.Columns("E:E").ColumnWidth = 9.43
.Columns("F:F").ColumnWidth = 2.86
.Columns("G:G").ColumnWidth = 17#
.Columns("H:H").ColumnWidth = 7.29
.Columns("I:I").ColumnWidth = 32#
.Columns("J:J").ColumnWidth = 32#
.Columns("K:K").ColumnWidth = 16.29
.Columns("L:L").ColumnWidth = 7.71
.Columns("M:M").ColumnWidth = 10.29
.Columns("N:N").ColumnWidth = 4.86
.Columns("O:O").ColumnWidth = 7.14
.Columns("P:P").ColumnWidth = 4.86
.Columns("Q:Q").ColumnWidth = 6.29
.Columns("R:R").ColumnWidth = 5.57
.Rows("3:103").EntireRow.AutoFit
End With
Next
Application.ScreenUpdating = True
End Sub
[/pre]
 
Hi Skidragon,


Thanks for sharing the MACRO... :)


By the way..

* Select all Cells.. and Change Protection "Unlocked"

* Select Only A:R Column .. Change Protection to "Locked"

* Protect Worksheet... Password is Optional...

* Provide all Permission.. Except Format Column.. (uncheck)


Will also "Lock the width of specific columns".. :)

but suggesting you to ignore it..


Regards,

=DEC2HEX(3563)
 
@red fuji
Hi!
BTW, yes, Debraj(ex-Roy) steps do work :)... and they work fine.
Check the uploaded file.
It works even if you don't provide all but default permissions, in fact the only that you should deny is "Apply format to columns", all the others might be any that suits your model.
Regards!
 

Attachments

  • Way to Lock Column Widths_ (for skidragon02 at chandoo.org).xlsx
    8.2 KB · Views: 22
@red fuji ,

This provided approach only works within 10 month from the date I post..
Sorry, this is approach is now expired..

Please start a new thread, with your query. and may be I have to write to the same answer.. and will work, due to re-activate of Expire time..
and as a new user.. please spend some time here..

Welcome to the forum.. :)
 
I cut and pasted the code into an open workbook and the
"
errored rather than giving
"
Out of curiosity why
Code:
.Columns("A:A").ColumnWidth = 5.57
rather than
Code:
.Columns(1).ColumnWidth = 5.57
?
 
Back
Top