Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Virtual Row Selection

I'm in a With statement and I'm trying to select one more rows depending on
the value of my variables. For example, say
Checkrow = 4
AddRow = 2
I want to insert 2 rows below row 4 this is what I'm trying:
..Rows((CheckRow + 1):(CheckRow + 1 + AddRow - 1)).Select
Selection.Insert Shift:=xlDown
This would be the same as:
Rows("3:4").Select
Selection.Insert Shift:=xlDown
but I'm getting a compile error: expected list separator or )

How do I make this work?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Virtual Row Selection

I'm pretty sure this will do what you want...

Checkrow = 4
AddRow = 2
Rows(CheckRow + 1).Resize(AddRow).Insert Shift:=xlShiftDown

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
I'm in a With statement and I'm trying to select one more rows depending
on
the value of my variables. For example, say
Checkrow = 4
AddRow = 2
I want to insert 2 rows below row 4 this is what I'm trying:
.Rows((CheckRow + 1):(CheckRow + 1 + AddRow - 1)).Select
Selection.Insert Shift:=xlDown
This would be the same as:
Rows("3:4").Select
Selection.Insert Shift:=xlDown
but I'm getting a compile error: expected list separator or )

How do I make this work?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Virtual Row Selection

VBE didn't recognize Shift:=xlShiftDown but I read the helpfile and this
worked:
Rows(CheckRow + 1).Resize(AddRow).Insert(xlShiftDown)

But this is perfect! Exactly what I needed. Thanks.

"Rick Rothstein" wrote:

I'm pretty sure this will do what you want...

Checkrow = 4
AddRow = 2
Rows(CheckRow + 1).Resize(AddRow).Insert Shift:=xlShiftDown

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
I'm in a With statement and I'm trying to select one more rows depending
on
the value of my variables. For example, say
Checkrow = 4
AddRow = 2
I want to insert 2 rows below row 4 this is what I'm trying:
.Rows((CheckRow + 1):(CheckRow + 1 + AddRow - 1)).Select
Selection.Insert Shift:=xlDown
This would be the same as:
Rows("3:4").Select
Selection.Insert Shift:=xlDown
but I'm getting a compile error: expected list separator or )

How do I make this work?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Virtual Row Selection

Odd, the line of code that I posted worked fine (I tested it before I posted
it)... did you copy it exactly as I wrote it? Your version also works on my
system, so you might as well use it. I'd be curious at to why what I posted
originally didn't work for you.

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
VBE didn't recognize Shift:=xlShiftDown but I read the helpfile and this
worked:
Rows(CheckRow + 1).Resize(AddRow).Insert(xlShiftDown)

But this is perfect! Exactly what I needed. Thanks.

"Rick Rothstein" wrote:

I'm pretty sure this will do what you want...

Checkrow = 4
AddRow = 2
Rows(CheckRow + 1).Resize(AddRow).Insert Shift:=xlShiftDown

--
Rick (MVP - Excel)


"Bishop" wrote in message
...
I'm in a With statement and I'm trying to select one more rows
depending
on
the value of my variables. For example, say
Checkrow = 4
AddRow = 2
I want to insert 2 rows below row 4 this is what I'm trying:
.Rows((CheckRow + 1):(CheckRow + 1 + AddRow - 1)).Select
Selection.Insert Shift:=xlDown
This would be the same as:
Rows("3:4").Select
Selection.Insert Shift:=xlDown
but I'm getting a compile error: expected list separator or )

How do I make this work?




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
VBA for Virtual Earth Kam Excel Programming 3 November 30th 08 01:16 PM
Virtual Clock Scott R Excel Worksheet Functions 4 October 1st 08 01:48 AM
Virtual PC Dhanushka Setting up and Configuration of Excel 2 September 2nd 08 05:50 PM
Virtual AutoFill Macro Greg Excel Programming 0 August 17th 07 02:03 AM
Tracking Virtual Memory Quaoar[_2_] Excel Programming 0 January 23rd 04 01:59 AM


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