View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
cbeebe cbeebe is offline
external usenet poster
 
Posts: 1
Default Excel VBA -- Finding last row in group of columns

I have a spreadsheet that gets its data from an Allen Bradley PLC usin
a program called XLReporter by Sytech (www.sytech.com). I am loggin
the cycle times of the operators for stations #1-#5 in columns
through K. The problem I am having is finding the last row that ha
data in it. Here is my current code:

Sub OverTaktHighlight()
For colIndex = 7 to 11
For rwIndex = 3 to 155
If Worksheets("Sheet1").Cells(rwIndex, colIndex)
Worksheets("Sheet1").Cells(3,21).Value Then
Worksheets("Sheet1").Cells(rwIndex, colIndex).Interior.ColorIndex = 6
Worksheets("Sheet1").Cells(rwIndex, colIndex).Font.ColorIndex = 3
End If
Next rwIndex
Next colIndex
End Sub

What this code does is compares the value of every cell to the value o
cell U3 and if the value is greater than U3 it changes the background t
yellow and the text to red. I would like to be able to get away fro
the hard coded "155" because I don't know how much data is going to b
in each sheet.

Also can I replace the Worksheets("Sheet1") with ActiveSheet? Or i
there a way to do this for all sheets in a workbook

--
Message posted from http://www.ExcelForum.com