Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello (again), I found a code that reports colored cells just I like to have (reporting the cell names). The request is how to combine or adapt this (if this is the way to do it) into the first mentioned part. The result should be reporting of the fields in the same way as the its reported the cells with the found/reported text (Filename/Sheetname/Cell).
It would be very great if somebody can create/change this for me. I'm struckling with this for many hours and tried everything, but....... :( ps. Because I got an overflow error when running below macro, I added a tempory part that select only the used cells. regards, Johan ------------------------------------------------ Sub SelectColoredCells() 'Tempory added this part. 'Select the area with used cells (otherwise you get a stack overflow error) Dim FirstCell As Range, LastCell As Range Set LastCell = Cells(Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Row, _ Cells.Find(What:="*", SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Column) Set FirstCell = Cells(Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlRows, _ SearchDirection:=xlNext, LookIn:=xlValues).Row, _ Cells.Find(What:="*", After:=LastCell, SearchOrder:=xlByColumns, _ SearchDirection:=xlNext, LookIn:=xlValues).Column) Range(FirstCell, LastCell).Select 'Macro for finding/reporting cells with filled color Dim rCell As Range Dim lColor As Long Dim rColored As Range 'Select the color by name (8 possible) 'vbBlack, vbBlue, vbGreen, vbCyan, 'vbRed, vbMagenta, vbYellow, vbWhite lColor = vbRed 'If you prefer, you can use the RGB function 'to specify a color 'lColor = RGB(0, 0, 255) Set rColored = Nothing For Each rCell In Selection If rCell.Interior.Color = lColor Then If rColored Is Nothing Then Set rColored = rCell Else Set rColored = Union(rColored, rCell) End If End If Next If rColored Is Nothing Then MsgBox "No cells match the color" Else rColored.Select MsgBox "Selected cells match the color:" & _ vbCrLf & rColored.Address 'Request....... :) 'Instead of reporting the colored cells in the meassagebox 'I want to reported them the same way as mentioned in earlier request. 'reporting the file/sheet/cell in the file with the macro thats run 'through files in a specific directory. End If Set rCell = Nothing Set rColored = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto search the worksheet name and use it in report | Excel Discussion (Misc queries) | |||
Search Files and Report Results in Date Range | Excel Programming | |||
create a report and have a search funtion to find data | Excel Discussion (Misc queries) | |||
Search and change text color or style only | Excel Programming | |||
Search for text, change font color | Excel Programming |