+ Reply to Thread
Results 1 to 2 of 2

VBA to clear contents of a specific cell when opening workbook

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    Grantham
    MS-Off Ver
    Excel 2010
    Posts
    1

    Angry VBA to clear contents of a specific cell when opening workbook

    Hi,

    I am trying to get VBA to clear the content of a cell when I open the workbook but keep getting Run-time error '1004' Method 'Sheets' of object_Global failed.

    I am using sub as below:

    Sub Macro4()

    Sheets("1 Pager").Select
    Range("Z1").Select
    Selection.ClearContents
    Range("B7:J7").Select

    End Sub

    and then calling it in the Workbook_Open routine in the ThisWorkbook Window as below:

    Private Sub Workbook_Open()

    Call Macro4

    End Sub

    Any help, I am a VBA novice.

    Thanks,

    Rob

  2. #2
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: VBA to clear contents of a specific cell when opening workbook

    Hi Rob,
    Please use code tages if you wish to place ceode.. use(#)
    Please Login or Register  to view this content.
    The code work perfectly.. i am able to clear the content on book open..

    Can u attach your book here.. so that lets see what error u get.. i am unable to see any error
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Clear contents in specific cell and the cells in the next 2 columns to the right
    By JRidge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2014, 01:25 AM
  2. [SOLVED] Clear contents of specific cells on the same row if a specific cell on that row is empty
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2014, 01:48 PM
  3. Code to clear contents of a cell based on specific criteria
    By srsev in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2013, 01:38 PM
  4. Clear cell contents on closing/opening without clearing formulas
    By CFT Brian in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2013, 03:47 PM
  5. code that will delete and clear specific contents in the workbook
    By Khanzaki in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-01-2013, 01:18 PM
  6. [SOLVED] Clear contents of cells on opening workbook
    By jason1970 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2013, 09:42 AM
  7. [SOLVED] How to clear the value of one cell upon opening or closing the workbook.
    By JET2011 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-31-2013, 09:00 AM

Tags for this Thread

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