Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Deleting lines with a variable.

Hello,

In my macro I want to delete some lines depending on a test.
I loop through some lines and do a check whether to delete the line.
I've a linenumber stored in a variable i. The range object does not
seem to accept my varaiable however. If I just enter the variable e.g.

Worksheets(asset).Range(i).Delete
or
Worksheets(asset).Range(i:i).Delete

Excel will not accept it. If I add quotes I get:

Worksheets(asset).Range("i").Delete (which is not accepted)
or
Worksheets(asset).Range("i:i").Delete (which deletes a column instead
of a row)

So, how do I delete a line with a linenumber stored in a variable? If
it's not allowed to use a variable in the rangeobject, what would be an
efficient work around?

Thanks in Advance
Wilco

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Deleting lines with a variable.

this would delete row 10 on sheet1

Sub r()
i = 10
Worksheets("sheet1").Rows(i).EntireRow.Delete
End Sub

--


Gary


wrote in message
ups.com...
Hello,

In my macro I want to delete some lines depending on a test.
I loop through some lines and do a check whether to delete the line.
I've a linenumber stored in a variable i. The range object does not
seem to accept my varaiable however. If I just enter the variable e.g.

Worksheets(asset).Range(i).Delete
or
Worksheets(asset).Range(i:i).Delete

Excel will not accept it. If I add quotes I get:

Worksheets(asset).Range("i").Delete (which is not accepted)
or
Worksheets(asset).Range("i:i").Delete (which deletes a column instead
of a row)

So, how do I delete a line with a linenumber stored in a variable? If
it's not allowed to use a variable in the rangeobject, what would be an
efficient work around?

Thanks in Advance
Wilco



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Deleting lines with a variable.

Ok, Thanks a lot!

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
DELETING LINES THAT ARE THE SAME IN A TABLE conditional format if cell contains word[_2_] Excel Discussion (Misc queries) 1 May 28th 09 03:04 AM
Deleting unused lines between used lines? Stevel Setting up and Configuration of Excel 1 November 25th 05 12:58 AM
Deleting multiple lines tammytlc Excel Discussion (Misc queries) 1 October 3rd 05 11:49 PM
Deleting lines really deletes lines! Jim[_28_] Excel Programming 1 October 2nd 03 03:32 PM
Deleting duplicate lines Tom Ogilvy Excel Programming 0 September 18th 03 04:27 PM


All times are GMT +1. The time now is 12:35 PM.

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

About Us

"It's about Microsoft Excel"