Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Delete contents of cells in a range based on value of a cell

I want to be able to delete the contents of a range of cells
(A100:K200) based on the values I manually enter into cells A1 and B1,
everything to run in Sheet1. A1's entry is the first row of the range
to delete (A100:K100) and B1's entry is the last row of the range
(A200:K200). Can someone provide a fairly simple macro for this?
Thanks in advance.

Michael
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Delete contents of cells in a range based on value of a cell

To deleted entire rows, assuming by your example that A1 would be 100 and B1
would be 200.

Sub dele()
Dim x As Long, y As Long
x = Range("A1").Value
y = Range("B1").Value
Rows(x & ":" & y).Delete
End Sub

However, if you only want to clear contents of columns A - K of those rows
and A1 is A100 and B1 is K200, then:

Sub dele2()
Dim x As String, y As String
x = Range("A1").Value
y = Range("B1").Value
Range(x & ":" & y).ClearContents
End Sub


"Michael Lanier" wrote in message
...
I want to be able to delete the contents of a range of cells
(A100:K200) based on the values I manually enter into cells A1 and B1,
everything to run in Sheet1. A1's entry is the first row of the range
to delete (A100:K100) and B1's entry is the last row of the range
(A200:K200). Can someone provide a fairly simple macro for this?
Thanks in advance.

Michael



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Delete contents of cells in a range based on value of a cell

Thanks so much for your help. I'll try it out when I get back on the
program tomorrow.

Michael
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
Delete ROW based on Cell Contents HeatherJ Excel Discussion (Misc queries) 4 February 11th 10 04:25 PM
Delete row based on contents of cell AndyG Excel Discussion (Misc queries) 6 November 17th 05 10:08 PM
Delete Row based on cell contents Steph[_6_] Excel Programming 6 November 1st 05 07:48 PM
Delete/clear a cell based on another cells contents jademaddy Excel Programming 2 May 19th 05 06:15 PM
How do I select a whole range and delete the contents of the cells? benthomas_duck Excel Programming 2 June 4th 04 02:31 AM


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