ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Converting numbers to column letters (https://www.excelbanter.com/excel-programming/296097-converting-numbers-column-letters.html)

Hawk

Converting numbers to column letters
 
In a VBA procedure, I have two integers representing
columns. For example, integers are 1 and 5 are referring
to columns A and E respectively. From the two integers, I
would like to create a string representing the column
letters.

Basically,
1 and 5 should result in "A:E"
2 and 6 should result in "B:F"
3 and 27 should result in "C:AA"

I will be using the string to reference a range of
columns...Range("A:E"). Any ideas would be greatly
appreciated. TIA...


Juan Pablo González

Converting numbers to column letters
 
Try using something like

Range(Cells(1, i), Cells(1, j)).EntireColumn

where i and j are your numbers. No need to get the string, just use the
range directly.

--
Regards,

Juan Pablo González

"Hawk" wrote in message
...
In a VBA procedure, I have two integers representing
columns. For example, integers are 1 and 5 are referring
to columns A and E respectively. From the two integers, I
would like to create a string representing the column
letters.

Basically,
1 and 5 should result in "A:E"
2 and 6 should result in "B:F"
3 and 27 should result in "C:AA"

I will be using the string to reference a range of
columns...Range("A:E"). Any ideas would be greatly
appreciated. TIA...




Bob Phillips[_6_]

Converting numbers to column letters
 
Range(Chr(col1+64) & ":" & Chr(col2+64))

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Hawk" wrote in message
...
In a VBA procedure, I have two integers representing
columns. For example, integers are 1 and 5 are referring
to columns A and E respectively. From the two integers, I
would like to create a string representing the column
letters.

Basically,
1 and 5 should result in "A:E"
2 and 6 should result in "B:F"
3 and 27 should result in "C:AA"

I will be using the string to reference a range of
columns...Range("A:E"). Any ideas would be greatly
appreciated. TIA...




Melanie Breden

Converting numbers to column letters
 
HiHawk,

Hawk wrote:
In a VBA procedure, I have two integers representing
columns. For example, integers are 1 and 5 are referring
to columns A and E respectively. From the two integers, I
would like to create a string representing the column
letters.

Basically,
1 and 5 should result in "A:E"
2 and 6 should result in "B:F"
3 and 27 should result in "C:AA"

I will be using the string to reference a range of
columns...Range("A:E"). Any ideas would be greatly
appreciated. TIA...


try this:

Range(Columns(1), Columns(5)).Address(0, 0)

--
Regards

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)


Hawk

Converting numbers to column letters
 
Thanks...Simple, but effective
-----Original Message-----
Try using something like

Range(Cells(1, i), Cells(1, j)).EntireColumn

where i and j are your numbers. No need to get the

string, just use the
range directly.

--
Regards,

Juan Pablo González

"Hawk" wrote in

message
...
In a VBA procedure, I have two integers representing
columns. For example, integers are 1 and 5 are

referring
to columns A and E respectively. From the two

integers, I
would like to create a string representing the column
letters.

Basically,
1 and 5 should result in "A:E"
2 and 6 should result in "B:F"
3 and 27 should result in "C:AA"

I will be using the string to reference a range of
columns...Range("A:E"). Any ideas would be greatly
appreciated. TIA...



.



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

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