View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Convert column value to alpha

Your problems are due to COLUNNS returning a number for the column and the
RANGE requires a letter. You need to use CELLS in this case

Dim ActColumn


Columns("A:B").Select
Columns("A:B").EntireColumn.AutoFit

LastRow = Range("A1").End(xlDown).Row

ActColumn = ActiveCell.Column

ActColumn2 = ActColumn + 2

Range(cells(1,ActColumn),cells(LastRow,ActRow)).cu t

cells(1,ActColumn2).Paste

Counter = 1
Do While Counter <= LastRow

range(cells(2,ActColumn2),cells(LastRow,ActColumn) ).Cut
cells(1,ActColumn3).Paste
ActColumn2 = ActColumn2 + 1
ActColumn3 = ActColumn3 + 1
Counter = Counter + 1

Loop



"Chris Premo" wrote:

I'm parsing through a Text file with excel and trying to minimize the
code. This is the code I've started with and would like to use a Do
While loop. I've defined my starting and ending points with the ActRow
and ActColumn statements. Unfortunately, the "ActiveCell.Column"
statement returns a numeric value (1 in this case) for Column "A".

How can I convert this to "A", then "B", then "C", etc until I reach
the "ActRow" value (in my case 30)?


Columns("A:B").Select
Columns("A:B").EntireColumn.AutoFit

Range("A1").Select
Selection.End(xlDown).Select
ActRow = ActiveCell.Row
Dim ActColumn
ActColumn = ActiveCell.Column

ActColumn2 = ActColumn + 2

Range(ActColumn & "1:" & ActColumn & ActRow).Select
Selection.Cut
Range(ActColumn2 & "1").Select
ActiveSheet.Paste

Do While Counter <= ActRow

Range(ActColumn2 & "2:" & ActColumn & ActRow).Select
Selection.Cut
Range(ActColumn3 & "1").Select
ActiveSheet.Paste
ActColumn2 = ActColumn2 + 1
ActColumn3 = ActColumn3 + 1
Counter = Counter + 1

Loop

--