selecting monthly tab based on input date

  • Hello,

    I am not a code writer! i was able to write a few macros due to google/youtube knowledge. Here is the long story short:

    In my office, we use an excel spreadsheet to keep track of dates, times, addresses, comments, etc. This is broken down into monthly tabs. The same information that goes on the main log has to also be entered onto a personal log and a back up log. Basically entering the same information three times.

    I wrote a few macros that allow the user to input the information. It then places the information in the appropriate cells. At the end it copies the row of cells, opens the main spreadsheet, and pasts the row in the last line.

    Here is the problem. Each month, I have to edit the macro to open the current months tab. Is there a way to have the macro select the correct tab based on the date that the user input?

    Process:
    1. message box asks for the date of the transaction MM/DD (8/1)
    2. Excel places the date into the cell as Aug-1

    I need the macro to be able to open the main spreadsheet and then open the AUG tab so it can paste the content in that line.
    Clear as mud?


    If i need to send the files I can.


    thanks for the help
    G

  • The code written is : Set wsTO = workbooks("2021 FIB Log.xlsm").Worksheets("AUG")


    I need the AUG to be automatically changed based on the date inputted.

  • will Left(the cell.Text, 3) get what you're after ?

    i dont know... i have never seen that before and have no idea where to put it into the code line.


    Any idea where and how it would fit into - Set wsTO = workbooks("2021 FIB Log.xlsm").Worksheets("AUG")


    also, i was mistaken. the cell formats the date as 1-aug. so i guess there is a "right" command too?


    Im a novice at VBA. if there isnt a video how to use it, it takes me much longer to figure it out.


    Thanks for the help

    G

  • Maybe something like this


  • Did that work for you?

    I was given a line of code from another forum that accomplished what it needed to do. I have not tried yours. but thank you for the help.


    their code was


    Set wsTO = Workbooks("2021 FIB Incident Log.xlsm").Worksheets(Format(wsFROM.[A2], "mmm"))

  • Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the URL from the address bar in your browser) to the cross-post. We are here to help so help us help you!




    Read this to understand why we ask you to do this



    https://www.excelguru.ca/content.php?184

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!