#1   Report Post  
daniel chen
 
Posts: n/a
Default Column names

Is there any code to convert column(number) to column(letters), and V.V.
e.g. 27 for AA, AB for 28
Thanks


  #2   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

=COLUMN(AA:AA)

--
Regards,

Peo Sjoblom


"daniel chen" wrote in message
...
Is there any code to convert column(number) to column(letters), and V.V.
e.g. 27 for AA, AB for 28
Thanks


  #3   Report Post  
daniel chen
 
Posts: n/a
Default

Hi, Peo
Great! Thanks. How about the other way?
i.e. 27 for AA

"Peo Sjoblom" wrote in message
...
=COLUMN(AA:AA)

--
Regards,

Peo Sjoblom


"daniel chen" wrote in message
...
Is there any code to convert column(number) to column(letters), and V.V.
e.g. 27 for AA, AB for 28
Thanks




  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

How about:

=SUBSTITUTE(ADDRESS(1,27,4),"1","")



daniel chen wrote:

Hi, Peo
Great! Thanks. How about the other way?
i.e. 27 for AA

"Peo Sjoblom" wrote in message
...
=COLUMN(AA:AA)

--
Regards,

Peo Sjoblom


"daniel chen" wrote in message
...
Is there any code to convert column(number) to column(letters), and V.V.
e.g. 27 for AA, AB for 28
Thanks



--

Dave Peterson
  #5   Report Post  
daniel chen
 
Posts: n/a
Default

Hi Dave,
Thank you for the code. I may be able to use it.

I have this code
Cells(1, 2) = "=VLOOKUP($A1,Sheet1!$AH$8:$AN$200,2,FALSE)"
And I want to make this constant range("$AH$8:$AN$200") a variable at the
beginning of the setup.
i.e. AH (which is col(34)) = Function(Cells(1, 10))
let's say Function1(cells(1, 10)) = cells(1, 10) + 29
Function2(cells(1, 10)) = cells(1, 10) + 35
If cells(1, 10) = 5 then, Function1(cells(1, 10)) = 34 which
is column("AH")
Function2(cells(1, 10)) = 40 which is column("AN")
AH AN depend on what is in cells(1, 10)

"Dave Peterson" wrote in message
...
How about:

=SUBSTITUTE(ADDRESS(1,27,4),"1","")



daniel chen wrote:

Hi, Peo
Great! Thanks. How about the other way?
i.e. 27 for AA

"Peo Sjoblom" wrote in message
...
=COLUMN(AA:AA)

--
Regards,

Peo Sjoblom


"daniel chen" wrote in message
...
Is there any code to convert column(number) to column(letters), and
V.V.
e.g. 27 for AA, AB for 28
Thanks



--

Dave Peterson





  #6   Report Post  
daniel chen
 
Posts: n/a
Default

Hi Dave,
I have it working, but I couldn't make the super formula to work.
Why is that?

Sub getdata()
Dim r As Integer
Dim c As Integer
Dim LR As Integer
Dim reg1 As Variant
reg1 = Cells(1, 27).Value
Range("AA2") = "=SUBSTITUTE(ADDRESS(1," & 29 + reg1 & ",4),""1"","""")"
Range("AA3") = "=SUBSTITUTE(ADDRESS(1," & 30 + 2 * reg1 &
",4),""1"","""")"
For LR = 1 To 200
If Cells(LR, 1) = "" Then Exit For
Next LR
For r = 1 To LR - 1
For c = 2 To 7
'Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$AH$8:$AN$200," & c & ",FALSE)"
'orginal
Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$" & Range("AA2") & "$8:$" &
Range("AA3") & "$200," & c & ",FALSE)" ' it works

'Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$" & "=SUBSTITUTE(ADDRESS(1," & 29
+ reg1 & ",4),""1"","""")" & "$8:$" & "=SUBSTITUTE(ADDRESS(1," & 30 + 2 *
reg1 & ",4),""1"","""")" & "$200," & c & ",FALSE)" ' does not work
Next c
Next r
Cells(1, 1).Select
End Sub

"daniel chen" wrote in message
...
Hi Dave,
Thank you for the code. I may be able to use it.

I have this code
Cells(1, 2) = "=VLOOKUP($A1,Sheet1!$AH$8:$AN$200,2,FALSE)"
And I want to make this constant range("$AH$8:$AN$200") a variable at the
beginning of the setup.
i.e. AH (which is col(34)) = Function(Cells(1, 10))
let's say Function1(cells(1, 10)) = cells(1, 10) + 29
Function2(cells(1, 10)) = cells(1, 10) + 35
If cells(1, 10) = 5 then, Function1(cells(1, 10)) = 34 which
is column("AH")
Function2(cells(1, 10)) = 40 which is column("AN")
AH AN depend on what is in cells(1, 10)

"Dave Peterson" wrote in message
...
How about:

=SUBSTITUTE(ADDRESS(1,27,4),"1","")



daniel chen wrote:

Hi, Peo
Great! Thanks. How about the other way?
i.e. 27 for AA

"Peo Sjoblom" wrote in message
...
=COLUMN(AA:AA)

--
Regards,

Peo Sjoblom


"daniel chen" wrote in message
...
Is there any code to convert column(number) to column(letters), and
V.V.
e.g. 27 for AA, AB for 28
Thanks



--

Dave Peterson





  #7   Report Post  
Dave Peterson
 
Posts: n/a
Default

I didn't realize you wanted to use a VBA routine...

dim reg1 as long
dim myRng as range

reg1 = activesheet.cells(1,27).value
with sht1
set myrng = .range(.cells(1,reg1+29),.cells(200,30+2*reg1))
end with

'I'm confused about what you're doing, but maybe something like...

activesheet.cells(r,c).formula _
= "=vlookup($A" & r & "," & myrng.address(external:=true) & "," _
& c & ",false)"







daniel chen wrote:

Hi Dave,
I have it working, but I couldn't make the super formula to work.
Why is that?

Sub getdata()
Dim r As Integer
Dim c As Integer
Dim LR As Integer
Dim reg1 As Variant
reg1 = Cells(1, 27).Value
Range("AA2") = "=SUBSTITUTE(ADDRESS(1," & 29 + reg1 & ",4),""1"","""")"
Range("AA3") = "=SUBSTITUTE(ADDRESS(1," & 30 + 2 * reg1 &
",4),""1"","""")"
For LR = 1 To 200
If Cells(LR, 1) = "" Then Exit For
Next LR
For r = 1 To LR - 1
For c = 2 To 7
'Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$AH$8:$AN$200," & c & ",FALSE)"
'orginal
Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$" & Range("AA2") & "$8:$" &
Range("AA3") & "$200," & c & ",FALSE)" ' it works

'Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$" & "=SUBSTITUTE(ADDRESS(1," & 29
+ reg1 & ",4),""1"","""")" & "$8:$" & "=SUBSTITUTE(ADDRESS(1," & 30 + 2 *
reg1 & ",4),""1"","""")" & "$200," & c & ",FALSE)" ' does not work
Next c
Next r
Cells(1, 1).Select
End Sub

"daniel chen" wrote in message
...
Hi Dave,
Thank you for the code. I may be able to use it.

I have this code
Cells(1, 2) = "=VLOOKUP($A1,Sheet1!$AH$8:$AN$200,2,FALSE)"
And I want to make this constant range("$AH$8:$AN$200") a variable at the
beginning of the setup.
i.e. AH (which is col(34)) = Function(Cells(1, 10))
let's say Function1(cells(1, 10)) = cells(1, 10) + 29
Function2(cells(1, 10)) = cells(1, 10) + 35
If cells(1, 10) = 5 then, Function1(cells(1, 10)) = 34 which
is column("AH")
Function2(cells(1, 10)) = 40 which is column("AN")
AH AN depend on what is in cells(1, 10)

"Dave Peterson" wrote in message
...
How about:

=SUBSTITUTE(ADDRESS(1,27,4),"1","")



daniel chen wrote:

Hi, Peo
Great! Thanks. How about the other way?
i.e. 27 for AA

"Peo Sjoblom" wrote in message
...
=COLUMN(AA:AA)

--
Regards,

Peo Sjoblom


"daniel chen" wrote in message
...
Is there any code to convert column(number) to column(letters), and
V.V.
e.g. 27 for AA, AB for 28
Thanks



--

Dave Peterson




--

Dave Peterson
  #8   Report Post  
daniel chen
 
Posts: n/a
Default

Hi Dave,
Truely grateful.
I am developing tools for analysis.
Try to conserve memories and time.

"Dave Peterson" wrote in message
...
I didn't realize you wanted to use a VBA routine...

dim reg1 as long
dim myRng as range

reg1 = activesheet.cells(1,27).value
with sht1
set myrng = .range(.cells(1,reg1+29),.cells(200,30+2*reg1))
end with

'I'm confused about what you're doing, but maybe something like...

activesheet.cells(r,c).formula _
= "=vlookup($A" & r & "," & myrng.address(external:=true) & "," _
& c & ",false)"







daniel chen wrote:

Hi Dave,
I have it working, but I couldn't make the super formula to work.
Why is that?

Sub getdata()
Dim r As Integer
Dim c As Integer
Dim LR As Integer
Dim reg1 As Variant
reg1 = Cells(1, 27).Value
Range("AA2") = "=SUBSTITUTE(ADDRESS(1," & 29 + reg1 &
",4),""1"","""")"
Range("AA3") = "=SUBSTITUTE(ADDRESS(1," & 30 + 2 * reg1 &
",4),""1"","""")"
For LR = 1 To 200
If Cells(LR, 1) = "" Then Exit For
Next LR
For r = 1 To LR - 1
For c = 2 To 7
'Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$AH$8:$AN$200," & c & ",FALSE)"
'orginal
Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$" & Range("AA2") & "$8:$" &
Range("AA3") & "$200," & c & ",FALSE)" ' it works

'Cells(r, c) = "=VLOOKUP($A" & r & ",Sht1!$" & "=SUBSTITUTE(ADDRESS(1," &
29
+ reg1 & ",4),""1"","""")" & "$8:$" & "=SUBSTITUTE(ADDRESS(1," & 30 + 2 *
reg1 & ",4),""1"","""")" & "$200," & c & ",FALSE)" ' does not
work
Next c
Next r
Cells(1, 1).Select
End Sub

"daniel chen" wrote in message
...
Hi Dave,
Thank you for the code. I may be able to use it.

I have this code
Cells(1, 2) = "=VLOOKUP($A1,Sheet1!$AH$8:$AN$200,2,FALSE)"
And I want to make this constant range("$AH$8:$AN$200") a variable at
the
beginning of the setup.
i.e. AH (which is col(34)) = Function(Cells(1, 10))
let's say Function1(cells(1, 10)) = cells(1, 10) + 29
Function2(cells(1, 10)) = cells(1, 10) + 35
If cells(1, 10) = 5 then, Function1(cells(1, 10)) = 34
which
is column("AH")
Function2(cells(1, 10)) = 40 which is column("AN")
AH AN depend on what is in cells(1, 10)

"Dave Peterson" wrote in message
...
How about:

=SUBSTITUTE(ADDRESS(1,27,4),"1","")



daniel chen wrote:

Hi, Peo
Great! Thanks. How about the other way?
i.e. 27 for AA

"Peo Sjoblom" wrote in message
...
=COLUMN(AA:AA)

--
Regards,

Peo Sjoblom


"daniel chen" wrote in message
...
Is there any code to convert column(number) to column(letters),
and
V.V.
e.g. 27 for AA, AB for 28
Thanks



--

Dave Peterson



--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to group similar column titles together???? vrk1 Excel Discussion (Misc queries) 2 April 30th 05 12:17 AM
Return Count for LAST NonBlank Cell in each Row Sam via OfficeKB.com Excel Worksheet Functions 12 April 17th 05 10:36 PM
Edit a column of names Martin ©¿©¬ @mandeREMOVETHIS.plus.com Excel Discussion (Misc queries) 5 February 4th 05 01:39 PM
Column A is Town, Column B is names. How can Excel add & tell how. Cindy Charts and Charting in Excel 3 January 13th 05 07:27 PM
how can I change the a,b,c, column headers in excel to names espray Excel Discussion (Misc queries) 1 January 13th 05 02:01 AM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"