Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Deleting a range of rows based on a variable; syntax error

I have a very basic question about how to express a certain range of rows
that I wish to delete in a macro. It's not tricky (I don't think), I just
haven't been able to find the right help file or webpage to explain the
phenomenon to me (I'm very new at this).

Basically I want to delete a number of rows based on a variable (integer).
If the variable is 1, for example, I want to delete rows 13-26. It is
possible for me to do this with the following line:

Worksheets("Math").Rows("13:26").Delete

The problem is, I can't figure out how I should do this when I want to bring
my variable into it. For example, I would love to be able to use:

Worksheets("Math").Rows(MyVariable * 13:MyVariable*13 + 13").Delete

But that's not the right syntax at all. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Deleting a range of rows based on a variable; syntax error

Hi,

myvariable = 1
Worksheets("Math").Rows(myvariable * 13 & ":" & myvariable * 13 + 13).Delete

Mike

"Babymech" wrote:

I have a very basic question about how to express a certain range of rows
that I wish to delete in a macro. It's not tricky (I don't think), I just
haven't been able to find the right help file or webpage to explain the
phenomenon to me (I'm very new at this).

Basically I want to delete a number of rows based on a variable (integer).
If the variable is 1, for example, I want to delete rows 13-26. It is
possible for me to do this with the following line:

Worksheets("Math").Rows("13:26").Delete

The problem is, I can't figure out how I should do this when I want to bring
my variable into it. For example, I would love to be able to use:

Worksheets("Math").Rows(MyVariable * 13:MyVariable*13 + 13").Delete

But that's not the right syntax at all. Any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Deleting a range of rows based on a variable; syntax error

Thanks - I could have sworn I had tried that, but I must have gotten some
part of it wrong. Your suggestion solved it perfectly, thanks.

"Mike H" wrote:

Hi,

myvariable = 1
Worksheets("Math").Rows(myvariable * 13 & ":" & myvariable * 13 + 13).Delete

Mike

"Babymech" wrote:

I have a very basic question about how to express a certain range of rows
that I wish to delete in a macro. It's not tricky (I don't think), I just
haven't been able to find the right help file or webpage to explain the
phenomenon to me (I'm very new at this).

Basically I want to delete a number of rows based on a variable (integer).
If the variable is 1, for example, I want to delete rows 13-26. It is
possible for me to do this with the following line:

Worksheets("Math").Rows("13:26").Delete

The problem is, I can't figure out how I should do this when I want to bring
my variable into it. For example, I would love to be able to use:

Worksheets("Math").Rows(MyVariable * 13:MyVariable*13 + 13").Delete

But that's not the right syntax at all. Any suggestions?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Deleting a range of rows based on a variable; syntax error

Another one:

Worksheets("Math").Rows(MyVariable * 13).resize(14).Delete



Babymech wrote:

I have a very basic question about how to express a certain range of rows
that I wish to delete in a macro. It's not tricky (I don't think), I just
haven't been able to find the right help file or webpage to explain the
phenomenon to me (I'm very new at this).

Basically I want to delete a number of rows based on a variable (integer).
If the variable is 1, for example, I want to delete rows 13-26. It is
possible for me to do this with the following line:

Worksheets("Math").Rows("13:26").Delete

The problem is, I can't figure out how I should do this when I want to bring
my variable into it. For example, I would love to be able to use:

Worksheets("Math").Rows(MyVariable * 13:MyVariable*13 + 13").Delete

But that's not the right syntax at all. Any suggestions?


--

Dave Peterson
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
macro syntax for selecting variable range Matt Excel Discussion (Misc queries) 1 October 31st 07 07:13 PM
Deleting Rows based on Column Critieria blackmanofsteel40 Excel Discussion (Misc queries) 1 September 7th 07 09:05 PM
Deleting rows based on number of characters catalfamo1220 Excel Discussion (Misc queries) 3 July 20th 06 06:31 PM
Deleting rows based on IF statement simmerdown Excel Discussion (Misc queries) 1 September 9th 05 02:18 PM
Deleting rows based on a cell value JPriest Excel Worksheet Functions 3 August 12th 05 05:44 PM


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