View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Chris Chris is offline
external usenet poster
 
Posts: 788
Default Convert column value to alpha

This is how I did it and it works:
************************************************** ********
'This Function changes the data in the file from a Column format
'to a row format. This supposes a "Two" column data file and only
'one record. This first column would contain the "Column Names" and
'the second column contains the actual data.

'This process sets the begining and ending column points that will
'be used to move the data.
Range("A1").Select
ActRow1 = ActiveCell.Row
ActColumn1 = ActiveCell.Column
LastRow = Range("A1").End(xlDown).Row
ActColumn2 = ActColumn1 + 2

'This process begins the move of the First Column information
Range(Cells(ActRow1, ActColumn1), Cells(LastRow, ActRow1)).Select
Range(Cells(1, ActColumn1), Cells(LastRow, ActRow1)).Cut
Cells(1, ActColumn2).Select
ActiveSheet.Paste

'This sets the new position set point for the rest of the First
'Column move. It loops through the data until the end point (LastRow)
'is reached.
ActColumn1 = ActiveCell.Column
Counter = 1
Do While Counter < LastRow
Range(Cells(2, ActColumn1), Cells(LastRow, ActColumn1)).Cut
ActColumn2 = ActColumn1 + 1
ActColumn1 = ActiveCell.Column + 1
Cells(1, ActColumn2).Select
ActiveSheet.Paste
Counter = Counter + 1
Loop

'This process sets the begining and ending column points that will
'be used to move the "Actual Data".
Range("B1").Select
ActRow1 = ActiveCell.Row + 1
ActColumn1 = ActiveCell.Column
LastRow = Range("B1").End(xlDown).Row
ActColumn2 = ActColumn1 + 1

'This process begins the move of the Second Column information
Range(Cells(ActRow1, ActColumn1), Cells(LastRow, ActRow1)).Select
Range(Cells(1, ActColumn1), Cells(LastRow, ActRow1)).Cut
Cells(2, ActColumn2).Select
ActiveSheet.Paste

'This sets the new position set point for the rest of the First
'Column move. It loops through the data until the end point (LastRow)
'is reached.
ActColumn1 = ActiveCell.Column
Counter = 1
Do While Counter < LastRow
Range(Cells(3, ActColumn1), Cells(LastRow + 1, ActColumn1)).Cut
ActColumn2 = ActColumn1 + 1
ActColumn1 = ActiveCell.Column + 1
Cells(2, ActColumn2).Select
ActiveSheet.Paste
Counter = Counter + 1
Loop

Columns("A:B").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select