+ Reply to Thread
Results 1 to 4 of 4

Copy sheet, add +1 to cell F1 -> name the copied sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    02-17-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    365
    Posts
    31

    Copy sheet, add +1 to cell F1 -> name the copied sheet

    Attached an excel, user should be able to press a button and
    1) new sheet is copied
    2) Week number is added to cell F1(+1 from the copied cell). On the first sheet the weeknumber is inserted manually, but for the new sheets it could be automated.
    3) new sheet is named "Week"+F1 value

    End result: new sheet is copied, week number is updated, sheet is renamed.
    The purpose of this excel is to use it as work allocation. Each week a new sheet is copied, where employees fill in their estimate of the coming weeks workload.
    Having the week numbering coming automatically would be super, but since now I have not been able to figure out how to do it. Any help would be highly appreciated.
    Attached Files Attached Files
    Last edited by Tsinos; 11-03-2021 at 12:34 PM.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Copy sheet, add +1 to cell F1 -> name the copied sheet

    Hi there,

    See if the following code does what you need:

    
    
    Sub CopySheet()
    
        Const sWORKSHEET_PREFIX As String = "Weekly data "
        Const sWEEK_NO_CELL     As String = "F1"
    
        Dim iCurentWeekNo       As Integer
        Dim iNewWeekNo          As Integer
        Dim wksLatest           As Worksheet
    
        With ThisWorkbook
            Set wksLatest = .Worksheets(.Worksheets.Count)
        End With
    
        iCurentWeekNo = wksLatest.Range(sWEEK_NO_CELL).Value
        iNewWeekNo = iCurentWeekNo + 1
    
        Application.DisplayAlerts = False
            wksLatest.Copy After:=wksLatest
        Application.DisplayAlerts = True
    
        With ActiveSheet
            .Name = sWORKSHEET_PREFIX & CStr(iNewWeekNo)
            .Range(sWEEK_NO_CELL).Value = iNewWeekNo
        End With
    
    End Sub
    The highlighted values can be changed to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    02-17-2021
    Location
    Helsinki, Finland
    MS-Off Ver
    365
    Posts
    31

    Re: Copy sheet, add +1 to cell F1 -> name the copied sheet

    Thanks, it works like a charm.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Copy sheet, add +1 to cell F1 -> name the copied sheet

    Hi again,

    Many thanks for your very prompt feedback and also for the Reputation increase - much appreciated!

    You're welcome - glad I was able to help.

    Best regards,

    Greg M

+ 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. Replies: 0
    Last Post: 07-28-2021, 08:00 AM
  2. Code to have cells copied from one sheet and pasted under cell in another sheet
    By fruitloop44 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-20-2017, 03:44 PM
  3. Copy row 5 active sheet then select where to copied row
    By MagicMan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2017, 10:58 AM
  4. [SOLVED] Add/copy row in one sheet when another sheet is copied/pasted using VBA
    By wildonln in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2016, 05:45 AM
  5. [SOLVED] Copy Row---> Add New Sheet----> Paste Copied Row
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-12-2014, 05:21 PM
  6. [SOLVED] Copy sheet based on Inputbox - data to be copied variable.
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 09-07-2012, 10:40 AM
  7. VBA Copy Sheet and and Different Cell to each copied sheet
    By Jerums in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2012, 02:08 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