Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Help with code, Please

Hi everyone,
I've been working on this piece of code and I can't find what I'm doing
wrong... please if anybody can take a look.

-Is not going through B16 to last row (when I'm doing it manualy it works)
-Somehow stops on the first 4 rows (is doing together "P" and "Ca"?)
-After this it runs to the end

Sub Check_High_Values()
Dim te As Long 'total elements
Dim LastEl As Long 'Last Element Row
Dim EndRow As Long 'Ending Row number
Dim lastC As String 'Last column letter
Dim LasR As Long ' L
Dim i As Long
Dim oRng As Range
Dim myValue As String

myfilename = Range("H3").Value

te = Range("F6").Value
LastEl = (te + 15)
EndRow = Range("B6").Value
lastC = Range("I100").Value

'look for elements and set high limits based on value

With Worksheets("ppb " & myfilename & " data").Range("B16").Select
For i = 1 To LastEl
'myValue = valueFind(ActiveCell.Offset(0, 0).Value) ' call function
to find value and check columns
On Error Resume Next
Set oRng = Cells.Find(What:=ActiveCell.Offset(0, 0).Value, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlDown)
'MatchCase:=False)
If Not oRng Is Nothing Then
If ActiveCell.Offset(0, 0).Value = "P" And _
ActiveCell.Offset(0, 3).Interior.ColorIndex = 6 Then

For Each c In Range(ActiveCell.Offset(0, 3).Address, lastC &
LastEl)
If c.Interior.ColorIndex = 6 And _
c.Value 5000 Then
c.Interior.ColorIndex = 44
End If
Next

ElseIf ActiveCell.Offset(0, 0).Value = "Na" Or _
ActiveCell.Offset(0, 0).Value = "Mg" Or _
ActiveCell.Offset(0, 0).Value = "K" Or _
ActiveCell.Offset(0, 0).Value = "Ca" Or _
ActiveCell.Offset(0, 0).Value = "Fe" And _
ActiveCell.Offset(0, 3).Interior.ColorIndex = 6 Then

For Each c In Range(ActiveCell.Offset(0, 3).Address, lastC &
LastEl)
If c.Interior.ColorIndex = 6 And _
c.Value 5500 Then
c.Interior.ColorIndex = 44
End If
Next

ElseIf ActiveCell.Offset(0, 0).Value < "P" And _
ActiveCell.Offset(0, 0).Value < "Na" And _
ActiveCell.Offset(0, 0).Value < "Mg" And _
ActiveCell.Offset(0, 0).Value < "K" And _
ActiveCell.Offset(0, 0).Value < "Ca" And _
ActiveCell.Offset(0, 0).Value < "Fe" And _
ActiveCell.Offset(0, 3).Interior.ColorIndex = 6 Then ' check
the rest

For Each c In Range(ActiveCell.Offset(0, 3).Address, lastC &
LastEl)
If c.Interior.ColorIndex = 6 And _
c.Value 500 Then
c.Interior.ColorIndex = 44
End If
Next
End If

End If
Next i
End With
Range("H2").Select

End Sub


--
gaba :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 83
Default Help with code, Please

Sorry about this one, I got it working.
Sometimes is good to walk away for a little while. Dave Peterson wrote an
answer to another post that help me see what was wrong here..

Thanks
Gaba
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
option buttons run Click code when value is changed via VBA code neonangel Excel Programming 5 July 27th 04 08:32 AM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


All times are GMT +1. The time now is 06:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"