Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 April 19th, 2005, 08:26 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default cell colouring EXCEL

I have this code:

Code:
If stripWhiteSpace(Left(Trim(UCase(Range(sRange).Text)), Len(Trim(UCase(gaDepSearch(j)))))) <> stripWhiteSpace(Trim(UCase(gaDepSearch(j)))) Then
                    Call WriteColourLog(Application.ActiveSheet.Name, "DEPARTURE STRING: " & _
                                                                      Chr(34) & UCase(gaDepSearch(j)) & Chr(34), sRange)
                Else
                    gbFoundDep = True
                    Range(sRange).Interior.ColorIndex = iColour

                    tempCol = Asc(extractString(sRange))
                    tempRow = extractNumber(sRange)

                     For k = tempCol To iTotalRows
                        sRange = Chr(tempCol) & k
                        tempRange = Chr(tempCol + 1) & k
                        If hasCityCode(Range(sRange).Text) Then

                                Range(sRange).Interior.ColorIndex = iColour

                        End If
                    Next
                End If
I want to color that cell and all cells to the right, until the are empty.



www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old April 19th, 2005, 09:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 217
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mega
Default

ok??

 - mega
Moving to C# .NET
 
Old April 20th, 2005, 11:14 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 180
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try surrounding the code with a do until...loop.

Range("A1").Select
Do Until ActiveCell.Value = ""
    Do Until ActiveCell.Value = ""
        If stripWhiteSpace(Left(Trim(UCase(Range(sRange).Text )), Len(Trim(UCase(gaDepSearch(j)))))) <> stripWhiteSpace(Trim(UCase(gaDepSearch(j)))) Then
            Call WriteColourLog(Application.ActiveSheet.Name, "DEPARTURE STRING: " & _
            Chr(34) & UCase(gaDepSearch(j)) & Chr(34), sRange)
        Else
            gbFoundDep = True
            Range(sRange).Interior.ColorIndex = iColour

            tempCol = Asc(extractString(sRange))
            tempRow = extractNumber(sRange)

            For k = tempCol To iTotalRows
                sRange = Chr(tempCol) & k
                tempRange = Chr(tempCol + 1) & k
                If hasCityCode(Range(sRange).Text) Then
                    Range(sRange).Interior.ColorIndex = iColour
                End If
            Next
        End If
    ActiveCell.Offset(0, 1).Select
    Loop
ActiveCell.Offset(1, -ActiveCell.Column + 1).Select
Loop

cheers

Matt






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get Excel Cell color populate .NET Framework 2.0 2 March 3rd, 2014 04:25 AM
Excel cell Formating Using C# veeruu C# 5 September 21st, 2011 01:56 PM
c# and Excel cell values hardboiled C# 0 November 16th, 2007 11:12 AM
cell references excel weazy Excel VBA 0 June 21st, 2006 09:28 AM
Unprotect a cell on Excel camf650 VBScript 2 April 14th, 2004 11:26 AM





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