Solved

Clear a Range in VBA - Excel 2007

Posted on 2012-04-04
4
579 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

623 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