View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default creating list of column headers

Hi rfhurley,

rfhurley wrote:
I'm trying to create a list of column headers for an enormous
spreadsheet, and I was wondering if there was an easy way to do this
without cutting each header individually and pasting it into a single
column.


I don't know if I understand exactly what you want to do. But here's some
code that will take the first row (assuming those are your headers) and put
them in a list in one column starting at A2 on the same sheet. This could
be adapted easily to place the list on a different sheet if you want.

Sub test()
Dim nLastCol As Integer

With ActiveSheet
nLastCol = .Cells(1, .Columns.Count).End( _
xlToLeft).Column
.Range(.Cells(1, 1), .Cells(1, nLastCol)).Copy
.Range("A2").PasteSpecial Paste:=xlPasteValues, _
Transpose:=True
End With
End Sub

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]