Lock Excel column width

Solved
GTA54 Posted messages 499 Status Member -  
GTA54 Posted messages 499 Status Member -
Hello,

I would like to know if it is possible to lock a column width?

Let me explain:

I have an Excel workbook with different tabs and tables in each tab. In these tabs, users enter their data into the tables.

Then I run an update with a macro button in Excel that selects the tables I have specified and displays them one after the other in a special tab. All the tables have the same structure!

So I would like to set the column widths (different for each column) and have them locked permanently. So that with each update I don't have to re-enter all the column widths.

I hope I have been clear. If you need more info, feel free to ask!

Thanks in advance. ;)

Configuration: Windows XP / Internet Explorer 6.0

--
"But how to do it,
How to tell him,
How to make him see,
My planet,
Artificial..."

-M-

1 answer

eriiic Posted messages 24581 Registration date   Status Contributor Last intervention   7 281
 
Hello,

Either you protect the sheet, or you redefine the column widths in your macro.

eric
-1
GTA54 Posted messages 499 Status Member 30
 
I'm not very good at macros.
Could you give me a little example?

Thanks in advance.
0
eriiic Posted messages 24581 Registration date   Status Contributor Last intervention   7 281
 
Re,

example:
Sub columnWidths() Dim width As Variant, col As Long width = Array(15, 25, 8) ' column widths in a table For col = 2 To 4 ' starting from column 2 Columns(col).ColumnWidth = width(col - 2) Next col End Sub

eric
0