+ Reply to Thread
Results 1 to 2 of 2

trying to duplicate worksheets in a workbook for each workday of the month

Hybrid View

  1. #1
    Registered User
    Join Date
    04-21-2022
    Location
    oklahoma
    MS-Off Ver
    Excel for Mac
    Posts
    6

    trying to duplicate worksheets in a workbook for each workday of the month

    The code i am using is as follows:

    Sub MakeMonth()
    Dim SH As Worksheet
    Dim myDate As Variant
    Dim D As Date, Y As Long
    Set SH = ActiveSheet

    myDate = InputBox(Prompt:="5/2/22", _
    Default:=Format(Date, "mm/dd/yy"))
    'If Y < 2000 Then Exit Sub
    'If Y > 2100 Then Exit Sub
    Application.ScreenUpdating = False
    myDate = CDate(myDate)

    'For D = DateSerial(Y, 1, 1) To DateSerial(Y, 12, 31)
    For iCtr = DateSerial(Year(myDate), Month(myDate), 1) To DateSerial(Year(myDate), Month(myDate) + 1, 0)
    Application.StatusBar = D
    SH.Copy after:=Sheets(Sheets.Count)
    'ActiveSheet.Range("A1").Value = D
    ActiveSheet.Name = Format(iCtr, "mm dd yy")
    Next
    Application.StatusBar = False
    Application.ScreenUpdating = True
    End Sub

    This code works fine for making a worksheet for everyday, however i only need every WORKDAY. I am new to VBA so i only understand the basics.

    What do i need to adjust in the above code to make it only duplicate for workday?

    Yes i know the answer is probably incredibly simple, but i can not figure it out.

    Thank you for your help!!
    Amber

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,936

    Re: trying to duplicate worksheets in a workbook for each workday of the month

        Application.ScreenUpdating = False
        myDate = CDate(myDate)
        For iCtr = DateSerial(Year(myDate), Month(myDate), 1) To DateSerial(Year(myDate), Month(myDate) + 1, 0)
            If (Weekday(iCtr) > 1) And (Weekday(iCtr) < 7) Then
                SH.Copy after:=Sheets(Sheets.Count)
                ActiveSheet.Name = Format(iCtr, "mm dd yy")
            End If 'workday
        Next iCtr
    Ben Van Johnson

+ 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. Duplicate Workbook for next month
    By scalemo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-03-2008, 09:08 PM
  2. Replies: 3
    Last Post: 12-04-2005, 04:10 PM
  3. how do i look through worksheets in a workbook to find duplicate
    By Connie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  4. [SOLVED] how do i look through worksheets in a workbook to find duplicate
    By Connie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  5. [SOLVED] how do i look through worksheets in a workbook to find duplicate
    By Connie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 AM
  6. [SOLVED] how do i look through worksheets in a workbook to find duplicate
    By Connie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. how do i look through worksheets in a workbook to find duplicate
    By Connie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. [SOLVED] how do i look through worksheets in a workbook to find duplicate
    By Connie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-25-2005, 12:10 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