+ Reply to Thread
Results 1 to 2 of 2

macro clearing wrong worksheet

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    macro clearing wrong worksheet

    The attached macro populated a worksheet summary from a main database. I then wanted to make it clear the worksheet first before overwriting.

    The default worksheet on opening file is "DriverDetails" so how the bottom half of the macro populated "DataSAFEPASS" without referencing it, I dont know but it did.

    Now I am trying to reference the sheet "DataSAFEPASS" to clear contents and added a message box after re referencing "DriverDetails" - it is clearing the wrong the wrong sheet. What am I Missing.

    Any help appreciated

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: macro clearing wrong worksheet

    You need to qualify the Range statement with a '.' (dot) to indicate it applies to the object specified in the With statement

    Please Login or Register  to view this content.
    As far as the Copy line goes the unreferenced range will apply to the active worksheet. That may be what you want but you should always explicitly reference the worksheet the Copy command is to use as the source, same as you do for the destination.
    Last edited by cytop; 02-17-2017 at 10:12 AM.

+ 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] Help? What am I doing wrong with clearing filters?
    By globulous in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-02-2015, 02:34 AM
  2. Help clearing linking and macro from worksheet
    By DanishDudeAU in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-09-2014, 05:11 AM
  3. VBA macro worksheet copying/clearing duplicate entries
    By RainbowLettering in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2013, 02:23 PM
  4. Excel Macro Worksheet saved in wrong format
    By David_Marsh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2011, 02:20 AM
  5. Clearing a Worksheet
    By CrazyFileMaker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2009, 08:05 PM
  6. [SOLVED] my macro is clearing the wrong sheet
    By Polarbear in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-02-2005, 04:05 PM
  7. [SOLVED] Worksheet clearing Macros?
    By Arlen in forum Excel General
    Replies: 4
    Last Post: 01-27-2005, 01:06 PM

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