+ Reply to Thread
Results 1 to 2 of 2

How to Delete a Range in Closed Workbook

  1. #1
    Resant
    Guest

    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


  2. #2
    kletcho@gmail.com
    Guest

    Re: 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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1