Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Kieranz
 
Posts: n/a
Default Insert Row before Macro Button


How do I create a macro which will allow me to insert a row on top. Eg
I have data in C3..H10. Row C11..H11 is blank but cells are formatted
(general, currency etc.). I have a macro button on B11, with the
following procedure attached to the button;

Sub InsertLineAbove()
ActiveCell.Offset(0,0).Range("A1").Select
Selection.EntireRow.Insert
ActiveCell.Offset(1,0).Range("A1").Select
End Sub

The probelm is when my cursor is on B11 or C11, it works beautifully,
but if the cursor is anywhere else and I click on the button (located
at B11) then it insert a line at the point where the cursor was. Which
is exactly what I don't want.

Thanks
Kieranz

PS Admin, suggestion to help newbies - is it possible to have a guide
in pdf which can be downloaded to read at leisure on using the forum
etc.


--
Kieranz
------------------------------------------------------------------------
Kieranz's Profile: http://www.excelforum.com/member.php...o&userid=27663
View this thread: http://www.excelforum.com/showthread...hreadid=471787

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

Are you trying to insert rows above a selected cell, if you are
take a look at
Insert a Row using a Macro to maintain formulas
http://www.mvps.org/dmcritchie/excel/insrtrow.htm

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Kieranz" wrote in message
...

How do I create a macro which will allow me to insert a row on top. Eg
I have data in C3..H10. Row C11..H11 is blank but cells are formatted
(general, currency etc.). I have a macro button on B11, with the
following procedure attached to the button;

Sub InsertLineAbove()
ActiveCell.Offset(0,0).Range("A1").Select
Selection.EntireRow.Insert
ActiveCell.Offset(1,0).Range("A1").Select
End Sub

The probelm is when my cursor is on B11 or C11, it works beautifully,
but if the cursor is anywhere else and I click on the button (located
at B11) then it insert a line at the point where the cursor was. Which
is exactly what I don't want.

Thanks
Kieranz

PS Admin, suggestion to help newbies - is it possible to have a guide
in pdf which can be downloaded to read at leisure on using the forum
etc.


--
Kieranz
------------------------------------------------------------------------
Kieranz's Profile: http://www.excelforum.com/member.php...o&userid=27663
View this thread: http://www.excelforum.com/showthread...hreadid=471787



  #3   Report Post  
Kieranz
 
Posts: n/a
Default


On click of the button (on B11) I should be able to copy that row
(including formulaes, format etc) one line above, irrespective where
the cursor may be positioned. That way I can continue to add rows only
as I need them.
Many thks


--
Kieranz
------------------------------------------------------------------------
Kieranz's Profile: http://www.excelforum.com/member.php...o&userid=27663
View this thread: http://www.excelforum.com/showthread...hreadid=471787

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
Assigning macro to button d Excel Discussion (Misc queries) 0 August 22nd 05 01:40 PM
How do I Assign Macro to a button? BellExcel Charts and Charting in Excel 4 May 20th 05 07:21 PM
Button fails to call macro when open an Excel via Intranet tigertax Excel Discussion (Misc queries) 1 April 12th 05 10:21 AM
Insert Line Macro Spyder Excel Discussion (Misc queries) 1 March 3rd 05 12:17 AM
Activate a macro to insert a row and copy the formuals from the rows above to the blank row oil_driller Excel Discussion (Misc queries) 1 February 11th 05 03:30 PM


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

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"