+ Reply to Thread
Results 1 to 2 of 2

Clear sheet & move to the end of workbook with different name

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-12-2018
    Location
    Clearwater, FL
    MS-Off Ver
    MS 365
    Posts
    217

    Clear sheet & move to the end of workbook with different name

    In my workbook called "Service Calendar 2018", I have a worksheet called "Intranet Calendar". I created a button on this sheet called Button 2. I want to click on this button and if the 1st sheet is last month, I would like for it to clear the cells B4:AF13 & B16:AF23, move the worksheet to the end of the workbook & rename it for the Month & year (ex. May '19). Anything that you can help with would be greatly appreciated. I have attached the workbook for your help!
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Clear sheet & move to the end of workbook with different name

    Hi,

    Here's one method

    Sub MoverToEnd()
        Dim stMonth1 As String, stMonth2 As String
        stMonth1 = Format(WorksheetFunction.EDate(Date, -1), "mmm") & " '" & Format(Date, "yy")
        stMonth2 = Format(WorksheetFunction.EDate(Date, 11), "mmm") & " '" & Format(WorksheetFunction.EDate(Date, 11), "yy")
        If Sheets(2).Name = stMonth1 Then
            Sheets(stMonth1).Move after:=Sheets(Sheets.Count - 1)
            Sheets(stMonth1).Range("B4:AF13,B16:AF23").ClearContents
            Sheets(stMonth1).Name = stMonth2 
    
        End If
    
    End Sub
    Note that there's a hidden sheet14 (December 2015) hence the "-1" in the Sheets.Count bit of code. If you remove the sheet then remove the "-1" as well.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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. Formula or Macro to Move Rows From Sheet 1 to Sheet 2 in Same Workbook
    By singerr45 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-03-2017, 02:31 PM
  2. Replies: 1
    Last Post: 05-27-2016, 07:45 PM
  3. Replies: 16
    Last Post: 04-30-2016, 07:34 AM
  4. [SOLVED] Move coulumns data of a sheet to diff other columns of other sheet in same workbook
    By ROHAN999 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 09-03-2013, 09:22 AM
  5. [SOLVED] Clear a range of cells on spread sheet after sending workbook in an email
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-04-2013, 11:39 AM
  6. Clear out all rows and move them to a corresponding sheet on the same workbook
    By ldorsi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2011, 01:13 AM
  7. macro to save to new workbook and clear sheet
    By groundhog in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2007, 01:15 PM

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