Solved

Clear a Range in VBA - Excel 2007

Posted on 2012-04-04
4
545 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Search for a value in Column? 5 21
ActiveX Listbox Multi Select in Excel 2010 8 16
Help with Excel formula 6 38
Issues with DAX Calculated Columns 6 13
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now