Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Clear a Range in VBA - Excel 2007

Posted on 2012-04-04
4
Medium Priority
?
586 Views
Last Modified: 2012-06-27
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

0
Comment
Question by:elwayisgod
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:kgerb
ID: 37808458
This will clear your named range

Range("ClearDataRange").Clear

Kyle
0
 

Author Comment

by:elwayisgod
ID: 37808468
Yep.  And it took my formatting with it :(   Forgot to put that stipulation in there :)
0
 
LVL 12

Accepted Solution

by:
kgerb earned 2000 total points
ID: 37808476
oops, sorry,  In that case do...

Range("ClearDataRange").ClearContents

Kyle
0
 

Author Closing Comment

by:elwayisgod
ID: 37808496
Perfect Thanks!!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question