+ Reply to Thread
Results 1 to 9 of 9

VBA to open, edit, save and close

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    YORK
    MS-Off Ver
    Excel 2003
    Posts
    22

    VBA to open, edit, save and close

    I Need a VBA to open, edit, save and close a number of excel files in a given folder.
    the cells i need to change are F5,I5 and P5. All cells are in the same place on each wookbook sheet, all the wookbooks are in the same folder. I have to update them from MIN to MIN1,MIN2 and MIN3 otherwise the consolidation does not work correctly. i would manually do these changes but its something that will be an on going problem.

    SO far i just have a macro to do this but with 500 files at once to change it takes some time. I would prefer it to be automated.
    PHP Code: 
    Sub Macro1()
    '
    Macro1 Macro
    '
    Keyboard ShortcutCtrl+w
    '
    Range("F5").Select
    ActiveCell.FormulaR1C1 = "MIN1"
    Range("I5").Select
    ActiveCell.FormulaR1C1 = "MIN2"
    Range("P5").Select
    ActiveCell.FormulaR1C1 = "MIN3"
    Range("G5").Select
    ActiveWorkbook.Save
    ActiveWindow.Close
    End Sub 
    Last edited by Cutter; 08-23-2012 at 11:31 AM. Reason: Corrected title

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Vab to open, edit, save and close

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Vab to open, edit, save and close

    Hi, pael45,

    shouldn´t your code feature Formula or FormulaR1C1 instead of Value?

    Could you please explain why you use another instance of Excel instead of the one running with the code?

    My complier won´t like mFolder as it hasd not been dimmed. Maybe you should alter your VBE to always show Option Explicit if a new module is inserted (won´t affect those that have been created prior to that).

    Ciao,
    Holger

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Vab to open, edit, save and close

    there is no reason, the code may be this
    Please Login or Register  to view this content.
    shouldn´t your code feature Formula or FormulaR1C1 instead of Value?
    I don't understand the question, the user wants paste strings
    Last edited by patel45; 08-23-2012 at 07:49 AM.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Vab to open, edit, save and close

    Hi, patel45,

    maybe you´re right about the pasting but if I read Min I think WorksheetFunction.Min.

    You dim aFolder, set mFolder to a value, and then again use aFolder.

    Option Explicit maybe a very good hint to follow and avoid typos like these.

    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    08-21-2012
    Location
    YORK
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Vab to open, edit, save and close

    Thanks I will test on Friday and post the results thanks for your help

  7. #7
    Registered User
    Join Date
    08-21-2012
    Location
    YORK
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Vab to open, edit, save and close

    BRILLIANT, works!

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA to open, edit, save and close

    @ AZZ70

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  9. #9
    Registered User
    Join Date
    08-21-2012
    Location
    YORK
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: VBA to open, edit, save and close

    I was aware but did not know how to change this. thanks for the help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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