Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I specify a clear contents range in Excel? 1

Status
Not open for further replies.

mlrmlr

Technical User
Mar 17, 2006
168
US
Hello,

I use this function to open an existing Excel workbook, clear the contents and paste new data. This has been working great for the most part. The problem is the "ClearContents" is erasing all of my data and formulas and I would like to start at a specific range. Can I specify the range I would like to clear? The data I would like to clear starts at A22:J100.

<BEGIN CODE>
'Open Excel report and clear existing data

Set myXL = CreateObject("Excel.Application")
Set myWB = myXL.Workbooks.Open("O:\WO.xls")
myWB.Sheets("Daily_WO_Report1").UsedRange.ClearContents
myWB.Save
myXL.Quit
Set myXL = Nothing
<END CODE>

Appreciate your help.
 
You can include a range:

[tt]myWB.Sheets("Daily_WO_Report1").Range("A22:J100").ClearContents[/tt]



Check out the Process TGML link below. It shows how to do code mark-up.
 
Thank you Remou,

It was exactly what I was looking for. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top