Solved

Highlighting in colour Rows of information in Excel using Visual Basic

Posted on 2003-11-25
8
295 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

813 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

13 Experts available now in Live!

Get 1:1 Help Now