+ Reply to Thread
Results 1 to 3 of 3

Clear contents from entire sheet

  1. #1
    Registered User
    Join Date
    08-30-2016
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    13

    Clear contents from entire sheet

    I am running a macro that takes data from a master sheet and copies it to an individual sheet. Each time the macro runs it duplicates the data. I need it to clear the data from the sheet each time before it runs. I am using code below.

    Sub Master()
    Dim x As Long, srcWks As Worksheet, destWks As Worksheet, rngData As Range, rng As Range
    Const str1 As String = "Pole Transfer"
    Set srcWks = Sheets("Master") 'Source sheet
    Set destWks = Sheets("Pole Transfer") 'Destination sheet
    Application.ScreenUpdating = False
    With srcWks
    If .AutoFilterMode Then .AutoFilterMode = False
    x = .Cells(.Rows.Count, 1).End(xlUp).Row
    Set rngData = .Range("A1", "M" & x)
    rngData.AutoFilter field:=2, Criteria1:=str1
    With Range("A1").CurrentRegion
    .Offset(1).Copy
    End With
    With destWks.Range("A" & Rows.Count).End(xlUp).Offset(1)
    .PasteSpecial Paste:=xlValues
    End With
    .AutoFilterMode = False
    End With
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,048

    Re: Clear contents from entire sheet

    You can use
    Please Login or Register  to view this content.
    to clear the sheet before each copy.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Clear contents from entire sheet

    Please take a moment to review Forum Rules about using Code Tags when posting code. Refer to Rule No. 3.

    http://www.excelforum.com/forum-rule...rum-rules.html

    Maybe:

    Please Login or Register  to view this content.

+ 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] Need to copy & clear row contents to another named sheet?
    By Gatewaya89 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-14-2016, 10:21 AM
  2. clear contents of entire sheet except the contents of the table
    By wayneg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-06-2015, 08:41 AM
  3. [SOLVED] I need to keep this macro from clear the entire sheet.
    By TomRet in forum Excel Programming / VBA / Macros
    Replies: 37
    Last Post: 04-08-2014, 11:11 PM
  4. [SOLVED] Clear contents in another sheet
    By Oeysbrei in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-12-2012, 05:20 PM
  5. Excel 2007 : Clear contents on all protected sheet
    By SEHRA in forum Excel General
    Replies: 0
    Last Post: 06-22-2011, 08:36 AM
  6. Clear sheet contents but retain Clipboard contents
    By nebb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2007, 01:42 PM
  7. Clear contents of unprotected cells in entire workbook with a macr
    By FinnGirl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2005, 01:05 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