+ Reply to Thread
Results 1 to 6 of 6

Struggling to create a macro that selects all the data on diff tabs....

  1. #1
    Forum Contributor
    Join Date
    12-08-2015
    Location
    London, England
    MS-Off Ver
    2021
    Posts
    145

    Struggling to create a macro that selects all the data on diff tabs....

    Hi folks,

    Could someone explain to me (in as basic language as possible), how i'd go about creating a macro that does the same function on each tab, but where the amount of rows of data on each tab is different?

    So on tab 1 i've got say 20 lines of data that i want to turn into a table, then on tab two i've got exactly same amount of columns and the data is in the same places etc there are just more rows. The way i've taught myself to make macros is to simply record the movements i'm making, but in this example that's no good

    Could i go into the editor itself and write in to do the same function as done in the first tab, but ensuring that it takes all the data instead of stopping where the first tab's info did.

    Does this make sense?

    Thanks

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,785

    Re: Struggling to create a macro that selects all the data on diff tabs....

    try this:

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: Struggling to create a macro that selects all the data on diff tabs....

    Hi

    Record macro for 1st tab. Check this twice is it working as intended.
    If difference is only with ROW quantity you can use variable which find out how many rows you need.

    For ex.
    Please Login or Register  to view this content.
    var lastRow get last row with data in column A.

    So, if you recorded macro and you will see something like:
    Please Login or Register  to view this content.
    it means on Sheet1 operation is done for 57 rows, then you can replace it with:

    Please Login or Register  to view this content.
    then, if Sheet2 or Sheet3 has more/less rows, operation will be applied to all non empty rows.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Forum Contributor
    Join Date
    12-08-2015
    Location
    London, England
    MS-Off Ver
    2021
    Posts
    145

    Re: Struggling to create a macro that selects all the data on diff tabs....

    Cheers - this sounds like exactly the sort of thing i was looking for

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,785

    Re: Struggling to create a macro that selects all the data on diff tabs....

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  6. #6
    Forum Contributor
    Join Date
    12-08-2015
    Location
    London, England
    MS-Off Ver
    2021
    Posts
    145

    Re: Struggling to create a macro that selects all the data on diff tabs....

    I've had a go at adding the above VB text into the existing macro, but i've not grasped/misunderstood what & where it's supposed to go

    This is possibly because i make several changes to the sheet during the macro on specific cells (i.e. change the top line, go to the bottom of the table and add a sum etc), so i can't really see a part of the code that says something like Range("A1:A57").select

    If i upload my macro into this site, could someone take a look and let me know how this could be made to work?

    Thanks

+ 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. [SOLVED] Create Multiple Tabs When Data Varies With Macro/VBA
    By Excel4444 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-29-2016, 08:26 PM
  2. [SOLVED] Create Macro, Userform or a searchbox to search data from table in excel in diff sheets
    By hanif in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 03-25-2014, 06:21 AM
  3. Attempting Macro to hide current tabs and create new ones with same info (Diff tab name)
    By theta25nupe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2014, 11:44 AM
  4. [SOLVED] How to create macro to copy select data, or row into newly created tabs
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-14-2013, 12:01 PM
  5. [SOLVED] Macro to send mail via lotus notes diff people diff attachment
    By mangeshp4 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-21-2013, 03:01 AM
  6. [SOLVED] Large amt of data needing to be split onto diff tabs
    By Arliene in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-18-2012, 10:00 AM

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