PC Review


Reply
Thread Tools Rate Thread

clear defined named cells' contents

 
 
Mint
Guest
Posts: n/a
 
      16th Jul 2007
i want to make a vba sub in excel file.
My sub is to clear the selected cells.
The cells are all in my defined region.
How can i write the such program.
How can i select the region?
Name("myregion").selected seems wrong.
please advice.
many thanks.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sk1C?=
Guest
Posts: n/a
 
      16th Jul 2007
Try either
Range("myregion").Clear
or
Range("myregion").ClearContents

Clear will remove formatting and comments as well as the cell contents.


"Mint" wrote:

> i want to make a vba sub in excel file.
> My sub is to clear the selected cells.
> The cells are all in my defined region.
> How can i write the such program.
> How can i select the region?
> Name("myregion").selected seems wrong.
> please advice.
> many thanks.
>
>

 
Reply With Quote
 
Mint
Guest
Posts: n/a
 
      16th Jul 2007
many thanks
Sub delete()

Range("Week1").Clear

End Sub

but:
Run-Time error '1004'
Method 'Range' of object '_Global' failed.
Do i have to active a worksheet?
please advice.

 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      16th Jul 2007
not really, just qualify the range:

Sub clear_range()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1") ' or whatever the name is
ws.Range("Week1").Clear
End Sub


--


Gary


"Mint" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> many thanks
> Sub delete()
>
> Range("Week1").Clear
>
> End Sub
>
> but:
> Run-Time error '1004'
> Method 'Range' of object '_Global' failed.
> Do i have to active a worksheet?
> please advice.
>



 
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
Iterate named range & clear contents Paul Wagstaff Microsoft Excel Discussion 6 11th Aug 2007 03:27 PM
Clear Contents Of Cells Where Value = 0 =?Utf-8?B?Y2FybA==?= Microsoft Excel Worksheet Functions 3 6th Jul 2007 06:02 PM
clear contents cells of unprotected cells =?Utf-8?B?RWQ=?= Microsoft Excel Programming 6 12th Jan 2006 06:09 PM
VBA Macro to Clear Named Cell Contents marajr@peelregion.ca Microsoft Excel Programming 3 3rd Jan 2006 08:42 PM
Defined Named cells lined to a Function Procedure =?Utf-8?B?c3dpZnRjb2Rl?= Microsoft Excel Worksheet Functions 4 11th Oct 2005 08:30 AM


Features
 

Advertising
 

Newsgroups
 


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