+ Reply to Thread
Results 1 to 6 of 6

VBA Copy Paste to New Sheet based on Month

  1. #1
    Registered User
    Join Date
    04-02-2019
    Location
    Ont
    MS-Off Ver
    2016
    Posts
    3

    VBA Copy Paste to New Sheet based on Month

    Hello,

    I have data that I would like to paste into a different Workbook's Sheet. The Sheets are categorized by Month ("Jan", "Feb", "Mar"..., "Dec")

    My below code prompts me to open the relevant Workbook i.e. 'Sales 2020'. I was wondering I could create a drop down list (showing months) in the original workbook that I can somehow reference in the last line of below code.

    HTML Code: 
    Does anyone suggest a different method/code to paste data into a different sheet each month without updating Sheet reference in code?
    Thank you

  2. #2
    Registered User
    Join Date
    04-02-2019
    Location
    Ont
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA Copy Paste to New Sheet based on Month

    I tried the below code to refer to drop down list which is in Worksheet("Month").Range("D2")

    But it get the Debug error on line two of code at dd = Workbooks("...filepath….".Worksheet('Month").Range("D2")

    Any advise

    HTML Code: 

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: VBA Copy Paste to New Sheet based on Month

    Just explain in a concise manner what you want to do.
    Don't leave any steps out.

  4. #4
    Registered User
    Join Date
    04-02-2019
    Location
    Ont
    MS-Off Ver
    2016
    Posts
    3

    Re: VBA Copy Paste to New Sheet based on Month

    I want to copy data from one workbook sheet and paste the data in another workbook's sheet. The destination (Sheet) to paste the data changes every month.
    I want to have a code that paste's the data in the relevant worksheet without updating my code every month; by creating a drop down list in excel that will reference the sheet name and have my vba code refer to the value selected in drop down list so the data paste
    s in relevant Sheet.

  5. #5
    Forum Contributor
    Join Date
    03-22-2017
    Location
    Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    230

    Re: VBA Copy Paste to New Sheet based on Month

    Q1: Did the file name is fixed?

    if yes, then you may code it in VBA.

    Example:
    Workbooks.open("\\fnpcplm02\home\243577\VBA practise\Copy 2020-02 TAR Volumes.xlsm")

    Q2: Did the Month Change is fixed stlye?

    Example:
    1. Daily, 29 Feb > Feb, and 1 Mar > Mar
    2. Prevous Month, 29 Feb > Jan, 1 Mar > Feb

    then you may use below VBA as Month, *Date mean Today
    1. Mon = Format(Date, "MMM")
    2 EDate = DateSerial(Year(Date), Month(Date) - 1, 1)
    Mon = Format(EDate, "MMM")

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: VBA Copy Paste to New Sheet based on Month

    Dropdown is in Cell E1 in Sheet1 where you copy the data FROM.
    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] Copy and Paste to another sheet filtering by month
    By DEJoseph in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2017, 10:58 AM
  2. cut copy paste based on new month
    By tryingtoexcelatexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2016, 05:57 AM
  3. Copy Paste data based on Month Names
    By kittu55 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-27-2015, 09:06 PM
  4. [SOLVED] Copy paste data one to multiple sheet based on cell value to sheet name
    By kannan1847 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2015, 12:54 AM
  5. [SOLVED] copy and paste entry for current month to another sheet vba
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-28-2014, 09:49 AM
  6. Copy and Paste Rows based on Criteria onto another sheet and sort based on oldest item
    By Kushal8684 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 05:37 AM
  7. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 AM

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