Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default HowTo insert a blank row and move existing down

I have

Date C1 C2 C3 C4
10/3 256 212 456 18
10/2 12 98 77 45

I want

Date C1 C2 C3 C4
blank row here - I'll put my new data on this row
10/3 256 212 456 18
10/2 12 98 77 45

p.s. I'm a VS 2003 C# guy not VB, for example

using Excel;

Excel.Worksheet sheet = (Excel.Worksheet)book.Worksheets["Passenger"];
sheet.get_Range("A13", "L99").Clear();
sheet.get_Range("L2", "L4").ClearContents();
Excel.Range rngNow = sheet.get_Range("J9", Missing.Value);



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default HowTo insert a blank row and move existing down

Hi Eggle,

Some one-liners for you,

' this inserts a blank row below the currently selected cell
ActiveCell.EntireRow.Insert Shift:=xlDown

' this inserts a blank row below row 2
Rows("2:2").Insert Shift:=xlDown

' this moves a range in sheet 'Passenger' one row down
Dim sht As Worksheet
Dim rng As Range
Dim dest As Range

Set sht = ThisWorkbook.Worksheets("Passenger")
Set rng = sht.Range("A2:E3")
Set dest = rng.Offset(1, 0)

rng.Cut
sht.Paste Destination:=dest

Ok, the last example is longer than one line.

BTW something you get in Excel that you don't see in VS is the macro
recorder. Look in Tools -- Macro. Makes it easy to work out this kind of
stuff.

Ed Ferrero
Microsoft Excel MVP
http://www.edferrero.com

I have

Date C1 C2 C3 C4
10/3 256 212 456 18
10/2 12 98 77 45

I want

Date C1 C2 C3 C4
blank row here - I'll put my new data on this row
10/3 256 212 456 18
10/2 12 98 77 45

p.s. I'm a VS 2003 C# guy not VB, for example

using Excel;

Excel.Worksheet sheet = (Excel.Worksheet)book.Worksheets["Passenger"];
sheet.get_Range("A13", "L99").Clear();
sheet.get_Range("L2", "L4").ClearContents();
Excel.Range rngNow = sheet.get_Range("J9", Missing.Value);





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
insert another page into an existing one Rachael Excel Worksheet Functions 1 October 10th 07 05:44 PM
How to add a blank row after each existing row? Stephanie Excel Discussion (Misc queries) 6 November 15th 06 04:11 AM
Macro code to test for blank row and insert blank row if false Mattie Excel Programming 2 March 29th 06 01:19 AM
Move Data Up One Row and Add On to Existing Dennis Excel Worksheet Functions 6 December 29th 05 08:09 PM
Move column to in-between existing columns Melissa Excel Discussion (Misc queries) 3 August 31st 05 01:43 PM


All times are GMT +1. The time now is 12:11 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"