ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting column width of a hidden column? (https://www.excelbanter.com/excel-programming/328606-getting-column-width-hidden-column.html)

Don Wiss

Getting column width of a hidden column?
 
Can my VBA code obtain the unhidden width of a hidden column? In order for
my print range to include all of a size-frozen text box, I have to find how
many visible columns cover it. This is no problem, but I have hard coded in
the macro the minimum width needed. I'd rather sum up the widths of A to H
(what the textbox spans if all columns are unhidden) and have the width
base be dynamic.

Don <www.donwiss.com (e-mail link at home page bottom).

Bob Phillips[_6_]

Getting column width of a hidden column?
 
Hi Don,

One way

Dim cWidth As Double
Dim i As Long

For i = 1 To 8
If Columns(i).Hidden Then
Columns(i).Hidden = False
cWidth = cWidth + Columns(i).ColumnWidth
Columns(i).Hidden = True
Else
cWidth = cWidth + Columns(i).ColumnWidth
End If
Next i

MsgBox cWidth


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Don Wiss" wrote in message
...
Can my VBA code obtain the unhidden width of a hidden column? In order for
my print range to include all of a size-frozen text box, I have to find

how
many visible columns cover it. This is no problem, but I have hard coded

in
the macro the minimum width needed. I'd rather sum up the widths of A to H
(what the textbox spans if all columns are unhidden) and have the width
base be dynamic.

Don <www.donwiss.com (e-mail link at home page bottom).





All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com