ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reference a Column by Number (https://www.excelbanter.com/excel-programming/362901-reference-column-number.html)

John Michl

Reference a Column by Number
 
I have a single cell named range called DateCreated_lbl. I'd like to
apply formatting to the entire column but can't seem to figure out the
proper syntax.

The following did not work:

Range(DateCreated_lbl).Column.ColumnWidth = 16

Columns.Range(DateCreated_lbl).ColumnWidth = 16

Is there a simple way?

Thanks

- John


John Michl

Reference a Column by Number
 
False Alarm. I figured it out. I was close but not quite there...

Columns(Range("DateCreated_lbl").Column).ColumnWid th = 16

- John

John Michl wrote:
I have a single cell named range called DateCreated_lbl. I'd like to
apply formatting to the entire column but can't seem to figure out the
proper syntax.

The following did not work:

Range(DateCreated_lbl).Column.ColumnWidth = 16

Columns.Range(DateCreated_lbl).ColumnWidth = 16

Is there a simple way?

Thanks

- John



Tom Ogilvy

Reference a Column by Number
 
Assuming if I did Insert=Name=Define, I would see a named range with the
name DateCreated_lbl, then

Range("DateCreated_lbl").EntireColumn.ColumnWidth = 16

--
Regards,
Tom Ogilvy

"John Michl" wrote in message
oups.com...
I have a single cell named range called DateCreated_lbl. I'd like to
apply formatting to the entire column but can't seem to figure out the
proper syntax.

The following did not work:

Range(DateCreated_lbl).Column.ColumnWidth = 16

Columns.Range(DateCreated_lbl).ColumnWidth = 16

Is there a simple way?

Thanks

- John




Tom Ogilvy

Reference a Column by Number
 
That works but is still only close <g

--
Regards,
Tom Ogilvy


"John Michl" wrote in message
oups.com...
False Alarm. I figured it out. I was close but not quite there...

Columns(Range("DateCreated_lbl").Column).ColumnWid th = 16

- John

John Michl wrote:
I have a single cell named range called DateCreated_lbl. I'd like to
apply formatting to the entire column but can't seem to figure out the
proper syntax.

The following did not work:

Range(DateCreated_lbl).Column.ColumnWidth = 16

Columns.Range(DateCreated_lbl).ColumnWidth = 16

Is there a simple way?

Thanks

- John





John Michl

Reference a Column by Number
 
Thanks Tom. My version works but yours makes more sense!

- John


Tom Ogilvy wrote:
Assuming if I did Insert=Name=Define, I would see a named range with the
name DateCreated_lbl, then

Range("DateCreated_lbl").EntireColumn.ColumnWidth = 16

--
Regards,
Tom Ogilvy

"John Michl" wrote in message
oups.com...
I have a single cell named range called DateCreated_lbl. I'd like to
apply formatting to the entire column but can't seem to figure out the
proper syntax.

The following did not work:

Range(DateCreated_lbl).Column.ColumnWidth = 16

Columns.Range(DateCreated_lbl).ColumnWidth = 16

Is there a simple way?

Thanks

- John




All times are GMT +1. The time now is 01:16 PM.

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