+ Reply to Thread
Results 1 to 7 of 7

copy rows from multiple tabs with a criteria to another tab

  1. #1
    Registered User
    Join Date
    04-12-2022
    Location
    Berkshire
    MS-Off Ver
    2013
    Posts
    6

    Question copy rows from multiple tabs with a criteria to another tab

    Hi

    Can anyone help I have multiple tabs in a excel document (e.g 580400 / 580401 / 580402 / 580403) and some of the entry lines in each tab I have in blue colour font (NOT CONDITIONAL FORMATTING)

    I am trying to copy all the blue font lines to another tab called "Sheet2" within the same workbook

    I have been able to make this work on one tab (580400) but struggling with including the other tabs (580401 / 580402 / 580403) how do I include the other tabs in this code ? I am new to VBA's

    Sub CopyColouredFontTransactions()

    Dim PeriodField As Range
    Dim PeriodCell As Range
    Dim Sheet1WS As Worksheet
    Dim Sheet2WS As Worksheet

    Dim x As Long

    Set Sheet1WS = Worksheets("580400")
    Set PeriodField = Sheet1WS.Range("A2", Sheet1WS.Range("A2").End(xlDown))
    Set Sheet2WS = Worksheets("Sheet2")


    For Each PeriodCell In PeriodField

    If PeriodCell.Font.Color = RGB(0, 176, 240) Then

    PeriodCell.Resize(1, 15).Copy Destination:= _
    Sheet2WS.Range("A1").Offset(Sheet2WS.Rows.Count - 1, 0).End(xlUp).Offset(1, 0)

    End If

    Next PeriodCell

    Sheet2WS.Columns.AutoFit

    End Sub
    Attached Files Attached Files
    Last edited by LS3594; 11-07-2022 at 06:50 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,302

    Re: copy rows from multiple tabs with a criteria to another tab

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.

    You probably don't to loop through the cells. You should be able to filter on blue text, then select and copy in one go.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-12-2022
    Location
    Berkshire
    MS-Off Ver
    2013
    Posts
    6

    Re: copy rows from multiple tabs with a criteria to another tab

    Many thanks for the advice TMS to upload have now attached a file with mocked up solution that allows me to copy all blue rows on 1 tab but as am new to VBA dont know how to add the other tabs to the code I have in sheet2

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,302

    Re: copy rows from multiple tabs with a criteria to another tab

    OK, try this. I have used your code rather than AutoFiltering as you don't have any filters set.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-12-2022
    Location
    Berkshire
    MS-Off Ver
    2013
    Posts
    6

    Re: copy rows from multiple tabs with a criteria to another tab

    Thank you TMS worked perfectly

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,302

    Re: copy rows from multiple tabs with a criteria to another tab

    You're welcome.



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

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,154

    Re: copy rows from multiple tabs with a criteria to another tab

    For future reference...Option making use of filter...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ 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. Copy Rows/Columns across multiple tabs
    By Jake_ in forum Excel General
    Replies: 1
    Last Post: 06-24-2022, 11:51 PM
  2. How to Copy Rows from multiple sheets onto another that match certain criteria
    By zlongshot in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2018, 01:52 AM
  3. [SOLVED] Copy rows from multiple worksheets with multiple criteria - greater than dynamic values
    By stackout in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2015, 04:36 PM
  4. How to copy rows based on multiple criteria from one worksheet to another ?
    By Caster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2015, 06:27 AM
  5. Copy multiple rows of a given criteria then find next.
    By zoenightshade in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2015, 09:05 AM
  6. [SOLVED] Select rows based on date range and copy to multiple tabs
    By B-Rell in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-01-2012, 09:27 AM
  7. Copy rows from one sheet to another based on multiple criteria
    By Abe8192 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-01-2012, 04:33 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