Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Runtime error 13-- Setting a variant Range?!

Why doesn't this work?



Dim MyRange as Variant

Set MyRange = ("C" &(Me.txtItem_Number.Value) & ":G"
&((Me.txtItem_Number.Value)+ 2))

Range(MyRange).ClearContents




I also tried Dim MyRange as Range. How can I work around this when I
need to clear a different area every time the macro runs?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Runtime error 13-- Setting a variant Range?!

ANSWERED MY OWN QUESTION:

Dim MyRange as Variant
MyRange = ("C" &(Me.txtItem_Number.Value) & ":G"
&((Me.txtItem_Number.Value)+ 2))

Range(MyRange).Clear Contents

That Set thing always gets me! erg!

:)



wrote:
Why doesn't this work?



Dim MyRange as Variant

Set MyRange = ("C" &(Me.txtItem_Number.Value) & ":G"
&((Me.txtItem_Number.Value)+ 2))

Range(MyRange).ClearContents




I also tried Dim MyRange as Range. How can I work around this when I
need to clear a different area every time the macro runs?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Runtime error 13-- Setting a variant Range?!

Try something like this...

Dim MyRange as Range

with Me.txtItem_Number
Set MyRange = Activesheet.Range("C" & .Value & ":G" & .Value + 2)
end with
MyRange.ClearContents
--
HTH...

Jim Thomlinson


" wrote:

Why doesn't this work?



Dim MyRange as Variant

Set MyRange = ("C" &(Me.txtItem_Number.Value) & ":G"
&((Me.txtItem_Number.Value)+ 2))

Range(MyRange).ClearContents




I also tried Dim MyRange as Range. How can I work around this when I
need to clear a different area every time the macro runs?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Runtime error 13-- Setting a variant Range?!

Dim MyRange As String

MyRange = ("C" & (Me.txtItem_Number.Value) & ":G" &
((Me.txtItem_Number.Value) + 2))

Range(MyRange).ClearContents


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

wrote in message
ups.com...
Why doesn't this work?



Dim MyRange as Variant

Set MyRange = ("C" &(Me.txtItem_Number.Value) & ":G"
&((Me.txtItem_Number.Value)+ 2))

Range(MyRange).ClearContents




I also tried Dim MyRange as Range. How can I work around this when I
need to clear a different area every time the macro runs?



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
runtime error 9 subscript out of range Nastack628 Excel Worksheet Functions 1 February 2nd 12 08:41 PM
Runtime Error '9' Subscript out of range HELP Brandon Johnson Excel Programming 1 August 2nd 06 06:46 PM
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Getting Excel Runtime Error 9: Subscript out of range Ph8te Excel Programming 6 July 14th 06 06:12 AM
Runtime error 91 when assigning range katarakt Excel Programming 1 April 24th 05 01:47 PM


All times are GMT +1. The time now is 02:26 AM.

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

About Us

"It's about Microsoft Excel"