Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How to Create a Header Row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default How to Create a Header Row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default How to Create a Header Row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,316
Default How to Create a Header Row

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default How to Create a Header Row

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
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
Can I create a header in table forms? Joseph P Excel Worksheet Functions 0 April 2nd 08 03:16 AM
How to create frozen header row? david.karr Excel Discussion (Misc queries) 2 May 8th 07 06:59 PM
create new sheets from a header row Craig[_24_] Excel Programming 2 December 20th 05 05:32 PM
How do I create a new header in Excel once to be used on all sheet thechuckster51 Setting up and Configuration of Excel 0 June 1st 05 12:21 AM
Create a two-line header programmatically Jeanne Conroy Excel Programming 1 November 24th 04 03:37 PM


All times are GMT +1. The time now is 01:49 PM.

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

About Us

"It's about Microsoft Excel"