• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Macros for excel file replicator|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Macros for excel file replicator|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosMacros for excel file replicator
sp_PrintTopic sp_TopicIcon
Macros for excel file replicator
Avatar
Anna Abgaryan

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 21, 2013
sp_UserOfflineSmall Offline
1
June 6, 2019 - 12:16 am
sp_Permalink sp_Print

Hi Team, I need your help. I have names in the column A. I need to replicate another simple excel base file by as many files as the names are in the column A and title them by names in the column A. I was using the below macros. On the small sample testing it went very well, however, when I went live, turned out that some of the newly created files titles unexplainably were changes with adding some (002) or (003) to new file titles. I can't understand the association for that. Can you please fix my macros, or help me with another " clean" macros. THANK YOU for all your help!!!

 

Sub test()

    Dim fso As Object, fName As String
    Dim fPathOld As String, Filename As String
    Dim sExt As String, x As Long, myPath As String
  
       
      fPathOld = "C:\Users\abgaryana\Desktop
rsp test\2018 OAIA RRSP Transfer Form_Formulaire de transfert de la PIAO 2018 au REER.xlsx"
        'Change as per your requirement
       
      fName = Dir(fPathOld)
     
      myPath = Mid(fPathOld, 1, InStr(1, fPathOld, fName) - 1)
     
      sExt = Mid(fName, InStr(1, fName, "."), 5)
     
     Set fso = CreateObject("Scripting.FileSystemObject")
   
       ThisWorkbook.Sheets("sheet1").Activate

        For x = 2 To Range("A" & Rows.Count).End(xlUp).Row
       
                Filename = Cells(x, 1).Value & sExt
               
                fso.Copyfile fPathOld, myPath & Filename
                       
                       
        Next x

End Sub

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
June 6, 2019 - 10:19 am
sp_Permalink sp_Print

Hi Anna,

Can you please share your workbook with data.

I thought you are maybe trying to overwrite a file that already exists, hence the 002, 003 etc added tothe names.  But the default for fso.Copyfile is to overwrite a file if it already exists so I'm not sure what is happening for you.

Regards

Phil

Avatar
Anna Abgaryan

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 21, 2013
sp_UserOfflineSmall Offline
3
June 6, 2019 - 10:36 am
sp_Permalink sp_Print

Thank you Philip,

 

So I have an excel file - I am attaching it - a form that needs to be re-created as many times as user names that I have in another file with a name title for each file. Lets say I have Anna in my list, I will need a copy of that file with name Anna, etc until all the names have a copy of that file.

I found this code in the web, I am not proficient with coding, so I can't really read it and understand what it exactly mean, however it somehow worked if not that weird thing with numbering.

So I am attaching the form to be replicated and the file with names and macro.

Please help me and thank you!  

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
June 11, 2019 - 11:39 am
sp_Permalink sp_Print

Hi Anna,

The name of the file you uploaded and the name in the code weren't the same, so once I amended the code, this worked fine.  There were only 2 names in the workbook so I can only test for those 2, but I had no problems.

Just one note though, your code uses Range("A" & Rows.Count).End(xlUp).Row which gives the number 525, which is the row your table ends on.  But you of course only want the rows with names in.

Regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Shanna Henseler, Lawrence Smith
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.