+ Reply to Thread
Results 1 to 8 of 8

Insert a row to all xlsm workbooks

  1. #1
    Forum Contributor
    Join Date
    10-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    221

    Insert a row to all xlsm workbooks

    Hi can someone help me with a vba macro please. I want insert a row in row 1 sheet 1 to all the xlsm files in a folder. The xlsm files are called different names in the folder.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Insert a row to all xlsm workbooks

    Try this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    10-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    221

    Re: Insert a row to all xlsm workbooks

    Hi I get an error on this part of the code U = Dir(P)

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Insert a row to all xlsm workbooks

    But, if you have a workbook up, that seems impossible? Did you try it more than once? What does the error say?

  5. #5
    Forum Contributor
    Join Date
    10-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    221

    Re: Insert a row to all xlsm workbooks

    Hi xladept, what do you mean by "If you have a workbook up"

    I tried the code more then once and it said "run time error 52: Bad file name or number"

    This is what I have in the active path: P = ActiveWorkbook.Path & "C:\Users\Administrator\Desktop\ANALYSIS\"

    The xlsm files in the folder ANALYSIS are called B1.xlsm,B7.xlsm, B20, V3.xlsm, V19.xslm
    Last edited by Roadhouse; 04-05-2018 at 09:08 AM.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Insert a row to all xlsm workbooks

    If you've got the path specified get rid of the ActiveWorkbook.Path i.e. change:

    Please Login or Register  to view this content.
    to just:

    Please Login or Register  to view this content.
    because it was trying to do a double path

  7. #7
    Forum Contributor
    Join Date
    10-31-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    221

    Re: Insert a row to all xlsm workbooks

    Hi xladept, that change worked thanks for your help. Is there any chance you can take a look at the other thread you replied too. The one where I have to call a macro to work on other workbooks?

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Insert a row to all xlsm workbooks

    You're welcome and thanks for the rep!

    I made a change to that other routine

+ 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] Macro that combines serveral workbooks stops on .xlsm files
    By Happytab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2017, 09:05 AM
  2. 'Reading' data from csv files in .xlsm Workbooks
    By hammer2 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-09-2015, 10:56 PM
  3. Difficulty in Linking to Unopened XLSM Workbooks
    By s_andrews in forum Excel General
    Replies: 2
    Last Post: 04-10-2014, 10:25 AM
  4. Split .xlsm workbook into multiple xlsm workbooks w/ 1 tab each
    By JenBR in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-23-2014, 07:05 PM
  5. Replies: 2
    Last Post: 10-04-2013, 10:12 AM
  6. Split .xlsm workbook into multiple xlxs. workbooks
    By thelenw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2011, 04:28 PM
  7. macro to save as xlsm, insert column and forumlas in table
    By jrtaylor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-29-2009, 12:25 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