#1   Report Post  
Spyder
 
Posts: n/a
Default Insert Line Macro

Does anyone know how to write a macro that will allow me to insert a row just
one row below the row with an "insert row" button on my worksheet. Basically
what I am trying to accomplish is to have a series of row categories where
information will be entered. If a user would like to add another line to a
category for an additional item, I want them to be able to click a button and
a blank line to be inserted above all the others in the category with the
same formatting as the other lines in the category. It would be great if
this was a generic macro that could be used for multiple categories on a
worksheet when assigned to each categories' separate button.

EAXAMPLE:

CATAGORY: CARS [Insert CARS line]
(After I click the "Insert CARS line" button, a new row with same formatting
as those below would be inserted here without negatively affecting the
ability of the "Insert CARS line" to complete the same functionality below.)
blue car 1999 good condition
green car 2000 poor condition
black car 2004 great condition

CATAGORY: TRUCKS [Insert TRUCKS line]
green truck 2001 poor condition
green truck 2001 good condition
black truck 2004 great condition

THANK YOU VERY MUCH FOR ANY INSIGHT!!!


  #2   Report Post  
David McRitchie
 
Posts: n/a
Default

Hi Spyder,
See http://www.mvps.org/dmcritchie/excel...row.htm#dclick
Most on the page are regular macros, this one is an Event Macro, which is installed
differently. Right click on the sheet tab, view code, insert the following
code from my web page:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True 'Eliminate Edit status due to doubleclick
Target.Offset(1).EntireRow.Insert
Target.EntireRow.Copy target.Offset(1).EntireRow
Target.Offset(1).EntireRow.SpecialCells(xlConstant s).ClearContents
End SubYou data might lend itself to macro examining the data.There is also subtotals on the data menu that might be of use.---HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]My Excel Pages:
http://www.mvps.org/dmcritchie/excel/excel.htmSearch Page: http://www.mvps.org/dmcritchie/excel/search.htm "Spyder"
wrote in message ...
Does anyone know how to write a macro that will allow me to insert a row just
one row below the row with an "insert row" button on my worksheet. Basically
what I am trying to accomplish is to have a series of row categories where
information will be entered. If a user would like to add another line to a
category for an additional item, I want them to be able to click a button and
a blank line to be inserted above all the others in the category with the
same formatting as the other lines in the category. It would be great if
this was a generic macro that could be used for multiple categories on a
worksheet when assigned to each categories' separate button.

EAXAMPLE:

CATAGORY: CARS [Insert CARS line]
(After I click the "Insert CARS line" button, a new row with same formatting
as those below would be inserted here without negatively affecting the
ability of the "Insert CARS line" to complete the same functionality below.)
blue car 1999 good condition
green car 2000 poor condition
black car 2004 great condition

CATAGORY: TRUCKS [Insert TRUCKS line]
green truck 2001 poor condition
green truck 2001 good condition
black truck 2004 great condition

THANK YOU VERY MUCH FOR ANY INSIGHT!!!




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
How do I insert a line feed in a formula? TX_KniveS Excel Worksheet Functions 5 October 31st 08 12:55 AM
Insert date in macro George Gee New Users to Excel 12 April 17th 06 05:44 AM
How do I insert the date using a macro tara0801 Excel Discussion (Misc queries) 4 February 10th 05 09:09 PM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM
Macro - Skipping a line PaulPoll Excel Worksheet Functions 4 December 21st 04 12:43 AM


All times are GMT +1. The time now is 11:57 AM.

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

About Us

"It's about Microsoft Excel"