Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Clear a range of data

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Clear a range of data

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Clear a range of data

Hi

Maybe this:

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

Regards,
Per

"Patrick C. Simonds" skrev i meddelelsen
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Clear a range of data

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"
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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Clear a range of data

You could always do this...

Sub ClearData()
Range("AQ1:DU1").ClearContents
End Sub

--
Rick (MVP - Excel)


"Patrick C. Simonds" wrote in message
...
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
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
Clear Range scott Excel Programming 3 December 20th 07 02:46 AM
Sub to clear range above n below diagonal Max Excel Programming 8 September 27th 07 06:48 AM
clear range of cells if another becomes blank bgg Excel Worksheet Functions 3 January 17th 07 11:32 PM
Clear Contents of a Selected Range Connie Excel Programming 1 October 11th 06 09:20 AM
Clear data range, and copy static value. [email protected] Excel Programming 1 December 23rd 05 07:44 AM


All times are GMT +1. The time now is 03:11 AM.

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"