![]() |
How to Delete a Range in Closed Workbook
Hi all,
Is it possible to delete a range in a closed workbook, without open it first? Any example would be appreciated. Thanks, Resant |
How to Delete a Range in Closed Workbook
You can't do it without opening the workbook, but you can do it without
visibly opening the workbook or seeing that excel is opening. If you are trying to access the workbook from somewhere other than excel, then I would suggest using a VB script file. If you are trying to delete the range from another workbook, then simply use the application.screenupdating = false to prevent people from seeing that you are opening the workbook. Something like this: Sub Macro1() Dim wbSource As Workbook Set wbSource = ActiveWorkbook Application.ScreenUpdating = False 'open the file Workbooks.Open Filename:="C:\My Documents\MyFile.xls" 'delete the range Sheet1.Range("H3:H8").ClearContents 'close the workbook and save ActiveWorkbook.Close True 'restore original workbook as active workbook wbSource.Activate Application.ScreenUpdating = True End Sub |
All times are GMT +1. The time now is 10:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com