Clear a Range in VBA - Excel 2007

Hi,

In the below code before it retrieves the data I need it to clear the data that is in a range named 'ClearDataRange'.


Open in new window

Sub GetData()

    'ActiveSheet.Unprotect

    X = EssVSetSheetOption(Null, 5, 1)
    Y = EssVSetSheetOption(Null, 11, True)
    X = EssVSetSheetOption(Null, 12, False)
    X = EssVSetSheetOption(Null, 13, True)
    X = EssVSetSheetOption(Null, 14, "Default")
    X = EssVSetSheetOption(Null, 18, False)
    X = EssVSetSheetOption(Null, 24, False)
    X = EssVSetSheetOption(Null, 25, False)


    X = EssVRetrieve(Null, Range("Retrieve_Data"), 1)
    If X = 0 Then
        MsgBox ("     Data Retrieve Successful.")
    Else
        MsgBox ("Retrieve Failed. Please try again.")
    End If

    Range("C15").Select
    'ActiveSheet.Protect

End Sub

Open in new window

elwayisgodAsked:
Who is Participating?
 
kgerbConnect With a Mentor Chief EngineerCommented:
oops, sorry,  In that case do...

Range("ClearDataRange").ClearContents

Kyle
0
 
kgerbChief EngineerCommented:
This will clear your named range

Range("ClearDataRange").Clear

Kyle
0
 
elwayisgodAuthor Commented:
Yep.  And it took my formatting with it :(   Forgot to put that stipulation in there :)
0
 
elwayisgodAuthor Commented:
Perfect Thanks!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.