ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   columncount and range? (https://www.excelbanter.com/excel-programming/368848-columncount-range.html)

leonidas[_58_]

columncount and range?
 

Hi,

I have a some columns from which the columnwidth should be changed. I
have written a piece of code to do that, but I get an error when using
it. I found out that iLastColumn3 gives the outcome "20" instead of
"T".
How should I change the code to get it working? Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
iLastColumn3 = Cells(iLastRow3, Columns.Count).End(xlToLeft).Column
Columns("B:B").ColumnWidth = 10
Columns("C", iLastColumn3).ColumnWidth = 9.14
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638


Die_Another_Day

columncount and range?
 
Columns should work with integers as well try:
Columns(3,iLastColumn3).ColumnWidth = 9.14

Die_Another_Day
leonidas wrote:
Hi,

I have a some columns from which the columnwidth should be changed. I
have written a piece of code to do that, but I get an error when using
it. I found out that iLastColumn3 gives the outcome "20" instead of
"T".
How should I change the code to get it working? Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
iLastColumn3 = Cells(iLastRow3, Columns.Count).End(xlToLeft).Column
Columns("B:B").ColumnWidth = 10
Columns("C", iLastColumn3).ColumnWidth = 9.14
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638



Tom Ogilvy

columncount and range?
 
Columns("C:C").Resize(,iLastColumn3-2).ColumnWidth = 9.14

--
Regards,
Tom Ogilvy

"leonidas" wrote:


Hi,

I have a some columns from which the columnwidth should be changed. I
have written a piece of code to do that, but I get an error when using
it. I found out that iLastColumn3 gives the outcome "20" instead of
"T".
How should I change the code to get it working? Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
iLastColumn3 = Cells(iLastRow3, Columns.Count).End(xlToLeft).Column
Columns("B:B").ColumnWidth = 10
Columns("C", iLastColumn3).ColumnWidth = 9.14
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638



Tom Ogilvy

columncount and range?
 
Just a heads up:
Columns doesn't accept two integer arguments to the best of my knowledge.


Maybe
Range(cells(1,3),cells(1,iLastcolumn3)).Entirecolu mn.ColumnWidth = 9.14

--
Regards,
Tom Ogilvy


"Die_Another_Day" wrote:

Columns should work with integers as well try:
Columns(3,iLastColumn3).ColumnWidth = 9.14

Die_Another_Day
leonidas wrote:
Hi,

I have a some columns from which the columnwidth should be changed. I
have written a piece of code to do that, but I get an error when using
it. I found out that iLastColumn3 gives the outcome "20" instead of
"T".
How should I change the code to get it working? Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
iLastColumn3 = Cells(iLastRow3, Columns.Count).End(xlToLeft).Column
Columns("B:B").ColumnWidth = 10
Columns("C", iLastColumn3).ColumnWidth = 9.14
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638




Die_Another_Day

columncount and range?
 
That's interesting. I've used that with Rows and it works fine. I
wonder why 1 dimension supports it and the other dimension doesn't.
Rows("1:10").Delete

Die_Another_Day
Tom Ogilvy wrote:
Just a heads up:
Columns doesn't accept two integer arguments to the best of my knowledge.


Maybe
Range(cells(1,3),cells(1,iLastcolumn3)).Entirecolu mn.ColumnWidth = 9.14

--
Regards,
Tom Ogilvy


"Die_Another_Day" wrote:

Columns should work with integers as well try:
Columns(3,iLastColumn3).ColumnWidth = 9.14

Die_Another_Day
leonidas wrote:
Hi,

I have a some columns from which the columnwidth should be changed. I
have written a piece of code to do that, but I get an error when using
it. I found out that iLastColumn3 gives the outcome "20" instead of
"T".
How should I change the code to get it working? Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
iLastColumn3 = Cells(iLastRow3, Columns.Count).End(xlToLeft).Column
Columns("B:B").ColumnWidth = 10
Columns("C", iLastColumn3).ColumnWidth = 9.14
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638





Tom Ogilvy

columncount and range?
 
columns("A:J") does work - but that is one arguement. Also 1:10 means
rows, not columns - so I suspect that is "consistent" with Range - but I
agree it isn't always intuitive

Range("1:10")
Range("A:J")

--
Regards,
Tom Ogilvy






"Die_Another_Day" wrote:

That's interesting. I've used that with Rows and it works fine. I
wonder why 1 dimension supports it and the other dimension doesn't.
Rows("1:10").Delete

Die_Another_Day
Tom Ogilvy wrote:
Just a heads up:
Columns doesn't accept two integer arguments to the best of my knowledge.


Maybe
Range(cells(1,3),cells(1,iLastcolumn3)).Entirecolu mn.ColumnWidth = 9.14

--
Regards,
Tom Ogilvy


"Die_Another_Day" wrote:

Columns should work with integers as well try:
Columns(3,iLastColumn3).ColumnWidth = 9.14

Die_Another_Day
leonidas wrote:
Hi,

I have a some columns from which the columnwidth should be changed. I
have written a piece of code to do that, but I get an error when using
it. I found out that iLastColumn3 gives the outcome "20" instead of
"T".
How should I change the code to get it working? Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
iLastColumn3 = Cells(iLastRow3, Columns.Count).End(xlToLeft).Column
Columns("B:B").ColumnWidth = 10
Columns("C", iLastColumn3).ColumnWidth = 9.14
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638





Die_Another_Day

columncount and range?
 
Well it makes a little more sense now. It does work with 2 Letters...
Columns("A:J").Delete

Whatever gets the job done. I like that offset idea though Tom.

Die_Another_Day
Die_Another_Day wrote:
That's interesting. I've used that with Rows and it works fine. I
wonder why 1 dimension supports it and the other dimension doesn't.
Rows("1:10").Delete

Die_Another_Day
Tom Ogilvy wrote:
Just a heads up:
Columns doesn't accept two integer arguments to the best of my knowledge.


Maybe
Range(cells(1,3),cells(1,iLastcolumn3)).Entirecolu mn.ColumnWidth = 9.14

--
Regards,
Tom Ogilvy


"Die_Another_Day" wrote:

Columns should work with integers as well try:
Columns(3,iLastColumn3).ColumnWidth = 9.14

Die_Another_Day
leonidas wrote:
Hi,

I have a some columns from which the columnwidth should be changed. I
have written a piece of code to do that, but I get an error when using
it. I found out that iLastColumn3 gives the outcome "20" instead of
"T".
How should I change the code to get it working? Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
iLastColumn3 = Cells(iLastRow3, Columns.Count).End(xlToLeft).Column
Columns("B:B").ColumnWidth = 10
Columns("C", iLastColumn3).ColumnWidth = 9.14
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638




leonidas[_59_]

columncount and range?
 

Hi,

The same problem but then with rows. I have tried the code below, but
it doesn't work.
How should I change the code to get it to work. Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
Rows("10:10").Resize(, iLastRow3).RowHeight = 15.75
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638


Die_Another_Day

columncount and range?
 
Just a guess but swap the "," and "iLastRow3" in the Resize function,
the normal syntax is Row, Column. Therefore the Columns resize worked
fine but the Rows needs changed

Die_Another_Day
leonidas wrote:
Hi,

The same problem but then with rows. I have tried the code below, but
it doesn't work.
How should I change the code to get it to work. Thanks in advance!


Code:
--------------------
iLastRow3 = Cells(Rows.Count, "B").End(xlUp).Row
Rows("10:10").Resize(, iLastRow3).RowHeight = 15.75
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=566638




All times are GMT +1. The time now is 07:59 AM.

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