+ Reply to Thread
Results 1 to 12 of 12

How to change worksheet that exports Data to current worksheet with button?

  1. #1
    Registered User
    Join Date
    07-30-2015
    Location
    Porto, Portugal
    MS-Off Ver
    2010
    Posts
    12

    Smile How to change worksheet that exports Data to current worksheet with button?

    Greetings, everyone

    I'm starting with excel, and I have a workbook with 3 initial pages(max,medium and min),
    which are identical in structure, but with different values, followed by 100 pages, also with different values and same structure.
    There are columns in all of these 100 pages that get their values directly from the first page (max).
    However, I would like to add a button with a macros that would automatically replace page 1 in this procedure with
    page 2, and another button to page 3. And a third button to return to feeding of the 100 sheets with page 1.

    For example, cell Di has the formula "='max'!Ci", for i in range 1 to 100. I click the button "min" and it turns the formula to "='min'!Ci".

    Sorry for the long text.

    Thanks in advance!

  2. #2
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: How to change worksheet that exports Data to current worksheet with button?

    A simple change from "min" to "max" could be achieved by recording a macro. All you have to do is perform a standard Ctrl+H Find & Replace, click to look into Formulas not Values. After recording you can draw a button and assign the macro to it.

  3. #3
    Registered User
    Join Date
    07-30-2015
    Location
    Porto, Portugal
    MS-Off Ver
    2010
    Posts
    12

    Re: How to change worksheet that exports Data to current worksheet with button?

    Thank you for the fast response, and your solution is simple and fast, but that requires 6 buttons and 6 macros(6 recordings):

    1 - change from min to max
    2 - change from min to medium
    3 - change from medium to max
    4 - change from medium to min
    5 - change from max to min
    6 - change from max to medium

    However, I'm already pleased with your solution!

  4. #4
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: How to change worksheet that exports Data to current worksheet with button?

    Maybe you don't need a macro at all. Do you want to be able to switch these things back and forth or is it just a one time change?

  5. #5
    Registered User
    Join Date
    07-30-2015
    Location
    Porto, Portugal
    MS-Off Ver
    2010
    Posts
    12

    Re: How to change worksheet that exports Data to current worksheet with button?

    Back and forth, it is my main issue :P

    Click "max" button and all values in all sheets are now fed by the max sheet
    Click "medium" button and all values in all sheets are now fed by the medium sheet
    Click "min" button and all values in all sheets are now fed by the min sheet

  6. #6
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: How to change worksheet that exports Data to current worksheet with button?

    See if you can work with this.
    Here is the entire code, 3 separate macros, 1 for each button.

    EndNumber

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

  7. #7
    Registered User
    Join Date
    07-30-2015
    Location
    Porto, Portugal
    MS-Off Ver
    2010
    Posts
    12

    Re: How to change worksheet that exports Data to current worksheet with button?

    That is awesome! :D
    Although the code is writen for just one column, I can easily extend it to the other columns.

    Thank you so much! Great work!

  8. #8
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: How to change worksheet that exports Data to current worksheet with button?

    Good luck

  9. #9
    Registered User
    Join Date
    07-30-2015
    Location
    Porto, Portugal
    MS-Off Ver
    2010
    Posts
    12

    Re: How to change worksheet that exports Data to current worksheet with button?

    Sorry, I forgot to ask:
    What code lines do I have to add in order to select all the 100 sheets afeter the first three sheets?

    My final goal is to do this procedure to all 100 sheets simultaneously.

    Thanks!

  10. #10
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: How to change worksheet that exports Data to current worksheet with button?

    I wish I knew, I can't write macros that run accross an entire workbook; single sheet only
    This line of code does the actual changing, and I have no idea how to make it do stuff in other sheets simultaneously.

    Cells(StartNumber, "A").Value = "=max!A" & StartNumber

    StartNumber is just the row number and "A" is the column letter. EndNumber is the number of times this procedure will be performed, in other words it is the total number of rows you have. The example macro only performs itself 10 times.


    EDIT:

    I found this command for switching sheets:

    Worksheets("Sheet1").Activate

    and this for looping through the entire workbook:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-30-2015
    Location
    Porto, Portugal
    MS-Off Ver
    2010
    Posts
    12

    Re: How to change worksheet that exports Data to current worksheet with button?

    I tried to use this WorksheetLoop in mine, but it is quite slow...
    If someday you find a code that can run many sheets
    and allow to perform many actions in each, please tell me.
    Your help has been precious!
    Thank you so much

  12. #12
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: How to change worksheet that exports Data to current worksheet with button?

    Thanks, good luck

+ 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. Click button to send data from one worksheet to fields on another worksheet
    By Nadzy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2014, 01:59 AM
  2. [SOLVED] Button to change worksheet reference
    By JimDandy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-05-2013, 12:58 AM
  3. Macro Button to copy data from one worksheet to second worksheet with criteria
    By vortex1fire in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2013, 06:24 PM
  4. Change code to look for current worksheet?
    By dalewms2 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-08-2011, 03:35 PM
  5. how to change default font in current worksheet only
    By WarrenC in forum Excel General
    Replies: 2
    Last Post: 05-28-2008, 04:18 PM
  6. A button that opens a new workbook and saves the current worksheet on to it
    By shilpz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2008, 02:50 AM
  7. [SOLVED] e-mail the current worksheet using a form button
    By Richard Smack in forum Excel General
    Replies: 2
    Last Post: 01-14-2005, 01:06 AM

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