+ Reply to Thread
Results 1 to 22 of 22

VBA coding for file creation

  1. #1
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Post VBA coding for file creation

    Hi All,

    I am creating a file on a monthly basis where the file has multiple sheets with a data sheet where the data being picked from data sheet with a Sumifs formula in each sheet.

    Since im changing the data sheet each month with a new data available for the current month from the system.

    Hence i need to copy paste the formula from for (ex) May month cell to June Month cell and replace the name in the formula from DATA_MAY to Data_June.

    Can anyone help with a dynamic formula or a coding which will help me in picking up the formula automatically once i pasted the data in the sheet.

    Excel Gurus please help me in automating this activity since this takes 4 hours on very month end (4 hours each day from 1st to 5th every month)

    Enclosed the file for your reference.

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    See next code
    Is asked for the new month: 1 to 12
    Previous month in all formula in all sheets will be replaced by new month string value


    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    Thanks for the response PCI.

    Could you please let me know whether the formula SUMIFS can be used in this macro.

    Thanks once again.

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    Yes certainly, can you give more details and example of the final result yoiu want
    Last edited by AliGW; 07-16-2018 at 03:46 AM.

  5. #5
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: VBA coding for file creation

    I would say no! It depends on the version of excel. I thought sumifs started with 2007? If you are running 2003 as per your profile no. then using sumproduct often gave the same result

  6. #6
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    @davsth
    As far as SUMIFS are already used in the first files sent I do not see any difficulties
    While SUPRODUCT is one of my favority functions easier to use than SUMIFS (for me)

  7. #7
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    The final result for me should be based on the reference’s of SUMIFS Function I need the data to be populated without any manual interventions. Since I’m copy pasting all the formulas from previous month to current say for July I will copy the formula from June and paste the same in July column and change the data sheet name as in references. Below is my formula

    =SUMIFS(Data_June!$P:$P,Data_June!$R;$R,$A8,Data_June!$B:$B,$E8)

    in each excel sheet I will copy paste the formula from previous month and change the reference name which takes more time for me and sometimes I miss some sheets as well.

  8. #8
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    The final result is what I have attached in the excel

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    Can you cross check the formulas in sheet "Kannan" : The first row is different to others rows ...!
    Can you explain what is missing from the previous macro ..! Is it the number of rows which is different every month, then is just needed to copy down the formula .. if formula are the same for each row ... see first comment

  10. #10
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    Thanks PCI

    Yes the number of rows may vary it might increase each month.

    and one more thing the macro does not take the formulas to next column which here is from "June" column to "July" column and the looping does not complete here.

    For Each Rg In WS.UsedRange
    Rg.Formula = Replace(Rg.Formula, Wkstg1, Wkstg2)
    Next Rg

    Thanks in advance.

  11. #11
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    What's up concerning the formula in the first row in sheet "Kannan"
    Last edited by PCI; 07-17-2018 at 05:19 AM.

  12. #12
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    Sorry may be I have put the formula wrongly in the Kannan sheet on first row.

    Or please help by replicating (copying the formula in June column and pasting it in July column)

    Thanks

  13. #13
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    Yes it’s running continuously

  14. #14
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    copying the formula in June column and pasting it in July column
    Yes clear see here
    Please Login or Register  to view this content.

  15. #15
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    Note :
    The tab (here "Data_July" ) must exist in the file, else the new formula will lead to a file selection to search for it

  16. #16
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    Thanks a lot and Sorry for the inconvenience caused.

    In the input box what should I provide date or month in number

  17. #17
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    In the imput box put:
    day/mont/year
    The day can be whatever you want, the month is the month to create, the same for the year
    note : It can be improve or simplify

  18. #18
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    Do you know that, instead of a using a string to record date in the header ( eg Jul'18 ) you could enter a real date and prepare the format to display it as you need:
    1/7/2018 for July 2018
    and use a custum format like : mmm ' yy

    Of course the macro needs to be updated because the date is searched in the header row to see which column to treat .

  19. #19
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    Thanks PCI I will check the macro and come back to you see if there is any doubt
    Last edited by aravindkm; 07-17-2018 at 06:30 AM.

  20. #20
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    OK
    Here another one with a more friendly input message

    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: VBA coding for file creation

    What should we give in input box. Just any date is enough

  22. #22
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA coding for file creation

    Yes, but a date which fits in the month you want to prepare, for example for July from 1/7/2018 to 31/7/2018
    In the last macro sent a default value is given

+ 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: 12
    Last Post: 11-20-2017, 04:45 PM
  2. Record Filename and Creation date of file used in another file
    By garveyarmy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-21-2014, 04:00 PM
  3. Stuck on coding Pivot Table/Chart creation for report NEWBY
    By BigJack in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2014, 08:31 AM
  4. Excel file creation dates do not match the windows creation date.
    By alexthapyro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2011, 12:14 PM
  5. [SOLVED] Would Like to Automate Batch File Creation and Text FIle Import
    By socrtwo in forum Excel General
    Replies: 2
    Last Post: 08-18-2006, 11:00 AM
  6. Add .LOG to .txt file on creation
    By Piranha in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-05-2005, 02:04 AM
  7. [SOLVED] PDF file creation
    By CraigCC in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2005, 08:05 AM

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