Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2005

Tip: Looking for answers? Try searching our database.

Find formatted cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Mills - 24 Mar 2005 15:16 GMT
Hi
Is there a way in VBA to scan a range of cells and pick up the references of
any cells that have a particular format applied? The range may have more
than one cell with the format applied and I want to be able to use the
references elsewhere in the workbook.

Many thanks.
Jim
Dave Peterson - 24 Mar 2005 15:50 GMT
xl2002 added the ability to find by format.

Before that you could have a macro that would search through your sheets looking
for cells that match a specific format.

But there are lots of things that are in the format of the cell.  If you limit
your search criteria (font/boldness/fill color/font color), you may even get a
few posts that can help.

> Hi
> Is there a way in VBA to scan a range of cells and pick up the references of
[quoted text clipped - 4 lines]
> Many thanks.
> Jim

Signature

Dave Peterson

Jim Mills - 24 Mar 2005 16:00 GMT
Dave

Thanks. I'm looking to find some code to scan the range looking for cells
with a backgound colour set, collect the cell reference(s). I want then to
try and apply the formatting to a similar range on a different sheet but I
can probably do that (!) if I can get some help with the first part.

Jim.
Dave Peterson - 24 Mar 2005 16:42 GMT
I'm kind of confused, but maybe this will help:

Option Explicit
Sub testme()
   Dim myBaseCell As Range
   Dim myCell As Range
   Dim myRng As Range
   Dim myColorIndex As Long
   
   Set myBaseCell = Nothing
   On Error Resume Next
   Set myBaseCell = Application.InputBox(Prompt:="select your cell", _
                         Type:=8).Cells(1)
   On Error GoTo 0
   
   If myBaseCell Is Nothing Then
       Exit Sub 'user hit cancel
   End If
   
   myColorIndex = myBaseCell.Interior.ColorIndex
   
   For Each myCell In Worksheets("sheet1").UsedRange
       If myCell.Interior.ColorIndex = myColorIndex Then
           If myRng Is Nothing Then
               Set myRng = myCell
           Else
               Set myRng = Union(myCell, myRng)
           End If
       End If
   Next myCell
   
   If myRng Is Nothing Then
       MsgBox "No cells found"
   Else
       MsgBox "Found here: " & myRng.Address(0, 0)
   End If
   
End Sub

> Dave
>
[quoted text clipped - 4 lines]
>
> Jim.

Signature

Dave Peterson

Jim Mills - 24 Mar 2005 17:17 GMT
Dave
Perfect, very many thanks.

Jim

> I'm kind of confused, but maybe this will help:
>
[quoted text clipped - 47 lines]
>
> Dave Peterson
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.