PC Review


Reply
Thread Tools Rate Thread

Clear a range of data

 
 
Patrick C. Simonds
Guest
Posts: n/a
 
      16th Mar 2009
I know I can use the code below to clear data from a range, but I need to
clear data from rng(1, 43) through rng(1, 125). Is there any way to do that
without having to write a line for each rng to be cleared?

Sub ClearData()

Dim rng
Set rng = Cells(ActiveCell.Row, 1)

rng(1, 43).Value = ""

End Sub

 
Reply With Quote
 
 
 
 
Michael Arch
Guest
Posts: n/a
 
      16th Mar 2009
Is this what you need?
set rng = Range(Cells(1,43),Cells(1,125))
rng.clearcontents
--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.




"Patrick C. Simonds" wrote:

> I know I can use the code below to clear data from a range, but I need to
> clear data from rng(1, 43) through rng(1, 125). Is there any way to do that
> without having to write a line for each rng to be cleared?
>
> Sub ClearData()
>
> Dim rng
> Set rng = Cells(ActiveCell.Row, 1)
>
> rng(1, 43).Value = ""
>
> End Sub
>
>

 
Reply With Quote
 
Per Jessen
Guest
Posts: n/a
 
      16th Mar 2009
Hi

Maybe this:

Range(Cells(ActiveCell.Row, 43), Cells(ActiveCell.Row, 125)).ClearContents

Regards,
Per

"Patrick C. Simonds" <(E-Mail Removed)> skrev i meddelelsen
news:(E-Mail Removed)...
>I know I can use the code below to clear data from a range, but I need to
>clear data from rng(1, 43) through rng(1, 125). Is there any way to do that
>without having to write a line for each rng to be cleared?
>
> Sub ClearData()
>
> Dim rng
> Set rng = Cells(ActiveCell.Row, 1)
>
> rng(1, 43).Value = ""
>
> End Sub
>


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      16th Mar 2009
Dim rng As Range
Set rng = ActiveSheet.Range(Cells(1, 43), Cells(1, 125))
With rng
.Value = ""
End With

Or more simply..................

ActiveSheet.Range(Cells(1, 43), Cells(1, 125)).Value = ""


Gord Dibben MS Excel MVP


On Mon, 16 Mar 2009 11:27:04 -0700, "Patrick C. Simonds"
<(E-Mail Removed)> wrote:

>I know I can use the code below to clear data from a range, but I need to
>clear data from rng(1, 43) through rng(1, 125). Is there any way to do that
>without having to write a line for each rng to be cleared?
>
>Sub ClearData()
>
>Dim rng
>Set rng = Cells(ActiveCell.Row, 1)
>
>rng(1, 43).Value = ""
>
>End Sub


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      16th Mar 2009
You could always do this...

Sub ClearData()
Range("AQ1U1").ClearContents
End Sub

--
Rick (MVP - Excel)


"Patrick C. Simonds" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I know I can use the code below to clear data from a range, but I need to
>clear data from rng(1, 43) through rng(1, 125). Is there any way to do that
>without having to write a line for each rng to be cleared?
>
> Sub ClearData()
>
> Dim rng
> Set rng = Cells(ActiveCell.Row, 1)
>
> rng(1, 43).Value = ""
>
> End Sub
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
duplicate data in range clear contents baha17@gmail.com Microsoft Excel Programming 1 18th Nov 2009 03:18 PM
Clear a range ordnance1 Microsoft Excel Programming 2 9th Nov 2009 03:11 AM
Clear a range ordnance1 Microsoft Excel Programming 1 8th Nov 2009 11:36 PM
I am asked to clear clipboard,yet there is no data to clear-help! =?Utf-8?B?UEogTycgTGVhcnk=?= Microsoft Excel Crashes 1 15th Apr 2006 12:30 PM
Clear data range, and copy static value. knox5731@gmail.com Microsoft Excel Programming 1 23rd Dec 2005 07:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:36 PM.