Solved

Highlighting in colour Rows of information in Excel using Visual Basic

Posted on 2003-11-25
8
294 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

861 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now