LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Insert a heading

I have this VBA code to insert a line in a spreadsheet everytime a values
changes.

How can I get a heading entered in column E of the inserted line.I thought
it would be relatively easy but obviously not.

col = ActiveCell.Column
lastrow = Cells(Rows.Count, col).End(xlUp).Row
If IsEmpty(Cells(1, col).Value) Then
firstrow = Cells(1, col).End(xlDown).Row
Else
firstrow = 1
End If
Set cell = Cells(lastrow, col)
While cell.Row firstrow + 6
If cell.Value < cell.Offset(-1, 0).Value Then
cell.EntireRow.Insert
Set cell = cell.Offset(-2, 0)
Else
Set cell = cell.Offset(-1, 0)
End If
Wend

Many thanks
Dave


 
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
how can I exclude a heading but show that heading in sheet. Hunter Excel Discussion (Misc queries) 4 January 8th 07 07:35 AM
In a table produce an value by column heading and row heading naflan Excel Worksheet Functions 1 December 27th 05 05:18 PM
AUTO INSERT PAGE BREAK FOR EACH COPIED HEADING wil4d Excel Discussion (Misc queries) 4 December 21st 05 04:02 AM
Can one insert a variable/cell ref. in the heading mykmag Excel Discussion (Misc queries) 7 May 16th 05 02:42 PM
How do I insert a heading into a column Essee68 Excel Worksheet Functions 1 March 15th 05 12:47 PM


All times are GMT +1. The time now is 06:16 AM.

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"