Solved

Highlighting in colour Rows of information in Excel using Visual Basic

Posted on 2003-11-25
8
298 Views
Last Modified: 2013-11-25
Hi
I would like to look at some financial data and highlight in colour rows of interest. The data would take the form below. I would use be using something like

If myOpen - 20 <= myLow And myHigh - 20 <= myClose then hightlight the  whole row

Or any other variation that crops up.


10/13/2003      9676      9783      9676      9764
10/14/2003      9763      9813      9732      9813
10/15/2003      9824      9850      9764      9803
10/16/2003      9799      9823      9730      9792
10/17/2003      9792      9816      9702      9722
10/20/2003      9722      9778      9706      9778
10/21/2003      9778      9784      9737      9748
10/22/2003      9742      9742      9580      9598
10/23/2003      9597      9622      9552      9613
10/24/2003      9601      9601      9498      9582
10/27/2003      9585      9664      9585      9608
10/28/2003      9610      9750      9610      9748
10/29/2003      9747      9787      9725      9775
10/30/2003      9772      9839      9754      9787
10/31/2003      9787      9840      9787      9801
11/03/2003      9802      9896      9802      9858

Hope this is enough info and enough points as I just want to get on with this!

Irazor


0
Comment
Question by:Irazor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
8 Comments
 
LVL 1

Expert Comment

by:ChristophMurczek
ID: 9817236
Hi,
how do you want to output this? You could use for example an MSFLexgrid-Control in a form. There you can set the background color for a row like this:

myFlexgrid.Col=0
myFlexgrid.Colsel=4
myFlexgrid.CellBackColor=vbGreen

hope this helps,
Christoph
0
 

Author Comment

by:Irazor
ID: 9817247
For the time being I would highlight the rows on the Spreadsheet.

Irazor
0
 
LVL 1

Expert Comment

by:ChristophMurczek
ID: 9817291
Hi again,
I just saw that you're working with Excel. Sorry 'bout that. it works like follows:

dim myWS as Excel.Worksheet

myWS.Range(Cell1,Cell2).Interior.Color = vbGreen

Cheers,
Christoph
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Irazor
ID: 9817300
Perhaps I should say that I only want to hightlight the 5 cells in the Row.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9817308
Range("A1:E1").Select
    With Selection.Interior
        .ColorIndex = 6
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
0
 
LVL 1

Accepted Solution

by:
ChristophMurczek earned 500 total points
ID: 9817341
OK. Try this:

myWS.Rows(Rowindex).Select

Christoph
0
 

Author Comment

by:Irazor
ID: 9823070
This is what I actually meant, something like this. Thanks for your help anyway.

Sub myanother()

  For i = 3 To 1483
         myOpen = Cells(i, 2).Value
         myHigh = Cells(i, 3).Value
         myLow = Cells(i, 4).Value
         myClose = Cells(i, 5).Value
 
       If myOpen - 20 < myLow And myHigh - 20 < myClose Then
       
           For cols = 1 To 6
                Cells(i, cols).Interior.ColorIndex = 47
          Next cols
     
       End If
 
  Next i
End Sub
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question