Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a set of data without headers. I want to programmatically insert a
blank row into Row 1, then add a header (e.g., the column letter) for each column in the data range. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can just record a macro to do that, unless there is more to what you want
than what you have described... -- HTH... Jim Thomlinson "DevDaniel" wrote: I have a set of data without headers. I want to programmatically insert a blank row into Row 1, then add a header (e.g., the column letter) for each column in the data range. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can tell Excel to print row and column heading directly from File/Page
Setup. Click on the Sheet tab of the Page Setup dialog box and locate the check box in the print panel about mid page. -- Kevin Backmann "DevDaniel" wrote: I have a set of data without headers. I want to programmatically insert a blank row into Row 1, then add a header (e.g., the column letter) for each column in the data range. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you don't want the row numbers you can run this code instead:
Sub ColumnHeadings() Dim varVal As Variant Dim strAddress As String ActiveSheet.Range("A1").Select ActiveCell.EntireRow.Insert varVal = ActiveCell.Offset(1).Value Do Until varVal = "" strAddress = Application.ConvertFormula( _ "R" & ActiveCell.Row & "C" & ActiveCell.Column, _ xlR1C1, xlA1, xlRelative) If Len(strAddress) = 3 Then strAddress = Left$(strAddress, 2) Else strAddress = Left$(strAddress, 1) End If ActiveCell.Value = strAddress ActiveCell.Offset(0, 1).Select varVal = ActiveCell.Offset(1).Value Loop End Sub -- Kevin Backmann "DevDaniel" wrote: I have a set of data without headers. I want to programmatically insert a blank row into Row 1, then add a header (e.g., the column letter) for each column in the data range. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It worked! Thanks for your help, Kevin. And thanks for taking the time to
consider my problem, Jim. -- Dan "Kevin B" wrote: If you don't want the row numbers you can run this code instead: Sub ColumnHeadings() Dim varVal As Variant Dim strAddress As String ActiveSheet.Range("A1").Select ActiveCell.EntireRow.Insert varVal = ActiveCell.Offset(1).Value Do Until varVal = "" strAddress = Application.ConvertFormula( _ "R" & ActiveCell.Row & "C" & ActiveCell.Column, _ xlR1C1, xlA1, xlRelative) If Len(strAddress) = 3 Then strAddress = Left$(strAddress, 2) Else strAddress = Left$(strAddress, 1) End If ActiveCell.Value = strAddress ActiveCell.Offset(0, 1).Select varVal = ActiveCell.Offset(1).Value Loop End Sub -- Kevin Backmann "DevDaniel" wrote: I have a set of data without headers. I want to programmatically insert a blank row into Row 1, then add a header (e.g., the column letter) for each column in the data range. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can I create a header in table forms? | Excel Worksheet Functions | |||
How to create frozen header row? | Excel Discussion (Misc queries) | |||
create new sheets from a header row | Excel Programming | |||
How do I create a new header in Excel once to be used on all sheet | Setting up and Configuration of Excel | |||
Create a two-line header programmatically | Excel Programming |