+ Reply to Thread
Results 1 to 11 of 11

need to run two consecutive VBA scripts

  1. #1
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    need to run two consecutive VBA scripts

    Hi all, I have two scripts in two separate modules. The first is run by clicking a hyperlink to find today’s date in a named row of dates. The second is a simple “Application.Goto ActiveCell, Scroll:=True” to bring that selected cell to the top left corner of the screen.

    The question is, how do I attach the second to the first to make the clicking of the link bring the cell with today’s date to the top left all in one motion?

    Any help is greatly appreciated.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    18,187

    Re: need to run two consecutive VBA scripts

    Just add one line before End Sub of 1st macro to run the 2nd procedure.
    e.g
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    3,772

    Re: need to run two consecutive VBA scripts

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

  4. #4
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: need to run two consecutive VBA scripts

    Thank you both for responding. Unfortunately, it doesn't work.
    I can click on the link and it finds the cell with today's date but doesn't run the second module. I go and manually run the second module and it also works. I will display the scrips so that hopefully someone can point out what I am still doing wrong. Thanks for your time and assistance.

    Please Login or Register  to view this content.
    Second Module:
    Please Login or Register  to view this content.
    Last edited by GregM56; 05-09-2021 at 12:11 PM. Reason: typo

  5. #5
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: need to run two consecutive VBA scripts

    Here's a sample spreadsheet
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    2,386

    Re: need to run two consecutive VBA scripts

    put the code you have in module1 into 'ThisWorkBook' module

  7. #7
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: need to run two consecutive VBA scripts

    Thanks for responding. Unfortunately that didn't change anything. Should I delete the module after copying it to 'ThisWorkBook'? I still have to manually run 'TopLeft' to get it to move.
    If it matters, the original module had (General) and (Workbook_Open) at the top. 'ThisWorkBook' has (General) and (Declarations).
    Last edited by GregM56; 05-09-2021 at 01:50 PM. Reason: adding comment

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    18,187

    Re: need to run two consecutive VBA scripts

    1) ThisWorkbook code module
    Please Login or Register  to view this content.
    2) Module2 code module
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jindon; 05-09-2021 at 11:24 PM.

  9. #9
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: need to run two consecutive VBA scripts

    Thank you for looking at this and working on changes for me. Unfortunately, either my intent was not clear or the fact that my sample spreadsheet was not wide enough still prevents it from working correctly. Please let me restate my intent.

    I would like to open the spreadsheet and click on the Today hyperlink located in cell A1 to instantly scroll to the left or right to place the Row2 cell that contains today's date in the far left location of the sheet which would be the second row and the second column. Today's date would become the Active Cell.

    Example: if the active cell is 'BH88' and today is May 10, 2021, when I press the link the macro should move column 'AF' as far left as possible (it would be the second column as the first column is frozen) and the current date would become the active cell.

    Thank you to everyone who takes the time to look at this again and I hope that I am more clear now.
    I am sending the spreadsheet again made large enough to actually test this as I have described it
    Attached Files Attached Files
    Last edited by GregM56; 05-10-2021 at 11:57 AM. Reason: typo

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    18,187

    Re: need to run two consecutive VBA scripts

    Then
    1) delete code in Thisworkbook module.
    2) to Sheet2 code module
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    06-08-2012
    Location
    Panama City, FL
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: need to run two consecutive VBA scripts

    Thanks for your time and assistance Jindon.
    Unfortunately I remain confused - please forgive my ignorance.
    Will you please put your suggested script in the spreadsheet and upload it?
    I just cannot see how what I am seeing can put cell ‘AF2’ (which contains today’s date) is moved to the second column from the left, given that I am beginning this with ‘BH88’ being the active cell.
    Sorry, but thanks again.

+ 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. Office Scripts
    By chris01395 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2021, 06:24 AM
  2. [SOLVED] Asigning consecutive textbox values to multiple consecutive cells...
    By Hovoruha Octavian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2019, 06:31 PM
  3. Need help on CMS VB Scripts
    By sudhakara in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2013, 07:21 AM
  4. Replies: 6
    Last Post: 03-23-2012, 06:03 PM
  5. Excel 2007 : how do I use scripts ?
    By mnesbitt in forum Excel General
    Replies: 4
    Last Post: 01-17-2012, 03:26 AM
  6. Combine 3 scripts into 1
    By pauldaddyadams in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2009, 06:14 AM
  7. For a website, are Excel scripts better than other programming language scripts?
    By Advice Pro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-01-2009, 02:07 PM

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