Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
runtime error 9 subscript out of range | Excel Worksheet Functions | |||
Runtime Error '9' Subscript out of range HELP | Excel Programming | |||
Runtime Error - Subscript out of range despite On Error statement | Excel Programming | |||
Getting Excel Runtime Error 9: Subscript out of range | Excel Programming | |||
Runtime error 91 when assigning range | Excel Programming |