+ Reply to Thread
Results 1 to 5 of 5

Macro to do one thing 1st time file opened - do somethin else in future openings

  1. #1
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Macro to do one thing 1st time file opened - do somethin else in future openings

    Good morning – Been trying for ovewr 5 hrs to put together pieces of code from here but failing to make all this happen - Really appreciate any help!
    When Master is run for 1st time Auto_Open to ask for job name. If number entered into input box – must re-ask for job name until answer is text or file closed via cancel button on input box. When job name given, macro needs to enter that into cell named Job_Name (which has word master in it until replaced by macro with input box data) and then save the file with job name + date + time.
    After file saved w name, auto_open macro needs to skip the input box and just go to a specific cell of one of the worksheets each time file opened in the future - but not to the worksheet / cell it went to the first time.
    Thanks for your help -

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Macro to do one thing 1st time file opened - do somethin else in future openings

    Could you attach an example workbook?

    Thanks!

  3. #3
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Macro to do one thing 1st time file opened - do somethin else in future openings

    Hello there,

    Attached is an example workbook that I believe accomplishes what you are attempting to do. I have inserted comments in the code that appear in green to help you understand what I've done. The codes are located in the workbook on open event and then also in Module1. Please let me know if you have any questions and if this works for you!

    P.S.

    You might want to hit Cancel on the inputbox when you first open the document and then select No. Then save the workbook into a folder. Close the document and reopen it. This way when the code runs you will be able to find the newly saved document as the code saves it in the folder the current workbook is in.

    Thanks!
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    07-02-2012
    Location
    Florida
    MS-Off Ver
    Home -Excel 2007, Work 2016
    Posts
    254

    Re: Macro to do one thing 1st time file opened - do somethin else in future openings

    WOW - Oh WOW!!!
    Thank you - Thank you - A hundred thousand times!

    When I look at your code and then at what I have done (a guy has to start somewhere) I have to wonder - is there a possibility this part of mine will not always follow through with what I want it to do?
    Your thoughts - Please
    Code[]
    Sheets("Job Info").Select
    ThisFile = Range("B3").Value
    Sheets("Weekly Billing Summary").Select
    Range("C12").Select
    ActiveWorkbook.SaveAs Filename:="C:\$ a For Wendi\$ Test of Macro\" & ThisFile & " " & Format(Now, "mm-dd-yyyy hh-mm-ss")
    FileExtStr = "xlsm": FileFormatNum = 52
    Application.ScreenUpdating = True
    End Sub
    Code[]

  5. #5
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Macro to do one thing 1st time file opened - do somethin else in future openings

    Hey there,

    For the question you asked me in your message.

    Add the following two lines

    Please Login or Register  to view this content.
    Below the code

    Please Login or Register  to view this content.
    So that the entire code looks like this
    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)

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