Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2009, 11:35 AM
Registered User
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How select/copy text in red color from array?

Hi,
I m looking for a code in order to find automatically all cells containing red text in the array (A2:E1000) then copy this selection in the sheet2.
I think this code is not complicated but I just started and need some help.
Thanks very much,
Julien
 
Old September 14th, 2009, 12:32 PM
Authorized User
 
Join Date: Jan 2009
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Here is a simple method:



Code:
Dim vRng, vCnt
Sub DoEm()
    vCnt = 1
    vR = 2
    vR1 = 2
    vRng = "A"
    While vCnt < 6
        While Range("vRng" & vR).Value <> ""
            If Range("vRng" & vR).Font.ColorIndex = 3 Then
                Range("vRng" & vR).Copy
                Sheets("Sheet2").Range("vRng" & vR1).PasteSpecial xlValues
                vR1 = vR1 + 1
            End If
            vR = vR + 1
        Wend
        vCnt = vCnt + 1
        SetColCase
        vR = 2
        vR1 = 2
    Wend
End Sub

Sub SetColCase()
        Select Case vCnt
        Case "2": vRng= "B"
        Case "3": vRng= "C"
        Case "4": vRng= "D"
        Case "5": vRng= "E"
      End Select
End Sub
Copy this code into your VBA Module and step through it and you'll get how it works. Someone may have better suggestion as not alot of folks use this type of method but for me, it's easy to understand and easy to learn on the fly. Hope this helps you.

Last edited by SheriV; September 14th, 2009 at 12:52 PM.. Reason: Accidentally hit the post by mistake.





Similar Threads
Thread Thread Starter Forum Replies Last Post
change the text color of (<xsl:value-of select="De ismailc XSLT 2 August 25th, 2008 07:25 AM
Need to change color of text in a text box? larry HTML Code Clinic 6 December 29th, 2006 05:14 AM
[red]Setting prob[/red] shivanshub ASP.NET 2.0 Professional 1 September 12th, 2006 10:01 AM
change font color of label red pritz BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 November 14th, 2005 03:48 AM
from color="red" to color='red' juaniux XSLT 2 November 16th, 2004 04:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.