+ Reply to Thread
Results 1 to 11 of 11

Find coloured cells and paste them into new worksheet

  1. #1
    Registered User
    Join Date
    04-26-2017
    Location
    Milan
    MS-Off Ver
    Office 2013
    Posts
    47

    Find coloured cells and paste them into new worksheet

    Hi,
    let me first say i'm a very beginner with macros...i've set something up looking posts and forums around but i'm not skilled.
    I would like to build a macro that searches within a worksheet all the cells with a specific color and paste the information of the coloured cells into another sheet together with the header of the column where the coloured cell is found and the value in a specific column in the same row

    i attached the sample file
    Basically the macro would need to find all yellow cells in sheet "Import Data" and copy them in sheet "Errors" together with the header in row 2 and the value in column A
    can anyone help to guide me?

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

    Re: Find coloured cells and paste them into new worksheet

    Can you try attached you file once again, please?
    There is nothing attached at this moment.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    04-26-2017
    Location
    Milan
    MS-Off Ver
    Office 2013
    Posts
    47

    Re: Find coloured cells and paste them into new worksheet

    trying to but does not let me attach anything

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

    Re: Find coloured cells and paste them into new worksheet

    Use Go advanced button, scroll down a bit and find Manage attachments link.
    On new page use choose button (choose your file), click Upload button (on right) then scroll down to Close window button, click it and post your post.

  5. #5
    Registered User
    Join Date
    04-26-2017
    Location
    Milan
    MS-Off Ver
    Office 2013
    Posts
    47

    Re: Find coloured cells and paste them into new worksheet

    attached now
    Attached Files Attached Files

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

    Re: Find coloured cells and paste them into new worksheet

    Please Login or Register  to view this content.
    check attached file.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-26-2017
    Location
    Milan
    MS-Off Ver
    Office 2013
    Posts
    47

    Re: Find coloured cells and paste them into new worksheet

    it looks great! just one question, is it normal that if i add some other "coloured" cells here and there they are not found?looks like it finding only those in columns H and I not the full list of columns,but maybe i was not clear at the beginning. by the way super helpful!!

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

    Re: Find coloured cells and paste them into new worksheet

    So you want to check all columns?

    EDIT: check attached file. You can grab all colours (all non white cells) as type of error in 'bolded' range of columns.

    Sub GetErrors()
    Dim cell As Range
    Dim lastRow1, lastRow2 As Long
    Dim errCount As Integer
    lastRow1 = Sheet2.Cells(Rows.Count, "H").End(xlUp).Row
    errCount = 0
    Sheet3.Columns("D:D").Interior.Color = 16777215
    Sheet3.Range("A2:D1000").ClearContents
    For Each cell In Sheet2.Range("H4:L" & lastRow1)
    If cell.Interior.Color <> 16777215 Then
    lastRow2 = Sheet3.Cells(Rows.Count, "A").End(xlUp).Row + 1
    Sheet3.Cells(lastRow2, 1).Value = Sheet2.Cells(cell.Row, 1).Value
    Sheet3.Cells(lastRow2, 2).Value = Sheet2.Cells(2, cell.Column).Value
    Sheet3.Cells(lastRow2, 3).Value = cell.Value
    Sheet3.Cells(lastRow2, 4).Interior.Color = cell.Interior.Color
    errCount = errCount + 1
    End If
    Next cell
    MsgBox ("Found: " & errCount & " errors")
    End Sub
    Attached Files Attached Files
    Last edited by KOKOSEK; 07-18-2019 at 06:34 AM.

  9. #9
    Registered User
    Join Date
    04-26-2017
    Location
    Milan
    MS-Off Ver
    Office 2013
    Posts
    47
    Quote Originally Posted by KOKOSEK View Post
    So you want to check all columns?
    Hi Kokosek,
    Thanks for the support you are providing!
    Yes,idea is to check all of them as a sort of validation of what is missing and working on conditional formatting,also on what is wrong,instead of checking manually column by column

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

    Re: Find coloured cells and paste them into new worksheet

    No, post #8 works only with hardcoded colouring.
    Checking CF is very, very complicated and I personally did not find any satisfied me vba code.

  11. #11
    Registered User
    Join Date
    04-26-2017
    Location
    Milan
    MS-Off Ver
    Office 2013
    Posts
    47

    Re: Find coloured cells and paste them into new worksheet

    Thanks Kokosek,
    i understand the point now since cells were not hardcoded...i then changed the logic to retrieve all the cells with a specific error message as per code below

    Sub GetErrors()
    Dim cell As Range
    Dim lastRow1, lastRow2 As Long
    Dim errCount As Integer
    lastRow1 = Sheet3.Cells(Rows.Count, "A").End(xlUp).Row
    errCount = 0
    Sheet4.Columns("D:D").Interior.Color = 16777215
    Sheet4.Range("A2:D1000").ClearContents
    For Each cell In Sheet3.Range("B5:AS" & lastRow1)
    If cell.Text = "CHECK" Or cell.Text = "WRONG" Then

    lastRow2 = Sheet4.Cells(Rows.Count, "A").End(xlUp).Row + 1
    Sheet4.Cells(lastRow2, 1).Value = Sheet3.Cells(cell.Row, 1).Value
    Sheet4.Cells(lastRow2, 2).Value = Sheet3.Cells(3, cell.Column).Value
    Sheet4.Cells(lastRow2, 3).Value = cell.Value
    Sheet4.Cells(lastRow2, 4).Interior.Color = cell.Interior.Color
    errCount = errCount + 1
    End If
    Next cell
    MsgBox ("Found: " & errCount & " errors")
    End Sub

    i still have visibility of all the impacted items not of the content, but i'll figure out how to also include this piece of info

+ 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] HELP! VBA to count number of coloured cells in a column and paste result in seperate tab
    By jordanleewillis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-25-2016, 08:29 AM
  2. [SOLVED] Formula to copy various coloured cells to relevant worksheet tabs
    By Lexy26 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-22-2015, 05:20 PM
  3. [SOLVED] Find Cell in different worksheet, Offset and Paste in multiple cells
    By JRidge in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-29-2014, 06:09 PM
  4. How can I count coloured cells (coloured using Conditional Formatting)
    By franfry in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-15-2013, 02:40 PM
  5. [SOLVED] Copy Coloured cells into new worksheet
    By slohman in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-21-2012, 08:25 PM
  6. Replies: 2
    Last Post: 01-20-2012, 09:44 AM
  7. Replies: 1
    Last Post: 01-19-2012, 03:07 PM

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