LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Missing blanks

I modified a procedure which Phillip was kind enough to send me a short
time ago. It does what it should but I have one problem which I cannot
seem to get round. In column 8 the first 12 cells will always be blank,
I cannot put anything in them in this situation so need to work round
it. Basically it means the procedure doesn't need to start until it
reaches row 13. I have tried putting in If statements like "if not
isempty" to jump the procedure forward but cannot get it to work. If I
put values in the cells, as long as there are not more than 6 of the
same it works but I don't have the luxury of being able to put values in
these in this circumstance. I would be grateful for any guidance.

Kind Regards
Graham
Turriff
Scotland

Sub gmhtrial()
Dim Rng As Range
Dim rngA As Range
Dim TotA As Double
Dim TotB As Double
Dim cl As Range
Dim NextRow As Integer
Dim ValueTomatch As String

Set Rng = ActiveSheet.UsedRange
Set rngA = Rng.Columns(8)
Rng.Interior.ColorIndex = xlNone
NextRow = 1
On Error Resume Next
For Each cl In rngA.Cells
If NextRow = cl.Row Then
ValueTomatch = cl.Text
TotA = cl.Offset(0, 1).Value
Select Case WorksheetFunction.CountIf(rngA, ValueTomatch)
Case 1
NextRow = cl.Row + 1
TotB = cl.Offset(0, 7).Value + cl.Offset(0, 9).Value
If Round(TotA, 2) < Round(TotB, 2) Then
Rng.Rows(cl.Row).Interior.ColorIndex = 6
End If
Case 2
NextRow = cl.Row + 2
TotB = cl.Offset(0, 7).Value + cl.Offset(0, 9).Value
TotB = TotB + cl.Offset(1, 7).Value + cl.Offset(1, 9).Value
If Round(TotA, 2) < Round(TotB, 2) Then
Rng.Rows(cl.Row & ":" & (cl.Row + 1)).Interior.ColorIndex = 6
End If
Case 3
NextRow = cl.Row + 3
TotB = cl.Offset(0, 7).Value + cl.Offset(0, 9).Value
TotB = TotB + cl.Offset(1, 7).Value + cl.Offset(1, 9).Value
TotB = TotB + cl.Offset(2, 7).Value + cl.Offset(2, 9).Value
If Round(TotA, 2) < Round(TotB, 2) Then
Rng.Rows(cl.Row & ":" & cl.Row + 2).Interior.ColorIndex = 6
End If
Case 4
NextRow = cl.Row + 4
TotB = cl.Offset(0, 7).Value + cl.Offset(0, 9).Value
TotB = TotB + cl.Offset(1, 7).Value + cl.Offset(1, 9).Value
TotB = TotB + cl.Offset(2, 7).Value + cl.Offset(2, 9).Value
TotB = TotB + cl.Offset(3, 7).Value + cl.Offset(3, 9).Value
If Round(TotA, 2) < Round(TotB, 2) Then
Rng.Rows(cl.Row & ":" & cl.Row + 3).Interior.ColorIndex = 6
End If
Case 5
NextRow = cl.Row + 5
TotB = cl.Offset(0, 7).Value + cl.Offset(0, 9).Value
TotB = TotB + cl.Offset(1, 7).Value + cl.Offset(1, 9).Value
TotB = TotB + cl.Offset(2, 7).Value + cl.Offset(2, 9).Value
TotB = TotB + cl.Offset(3, 7).Value + cl.Offset(3, 9).Value
TotB = TotB + cl.Offset(4, 7).Value + cl.Offset(4, 9).Value
If Round(TotA, 2) < Round(TotB, 2) Then
Rng.Rows(cl.Row & ":" & cl.Row + 4).Interior.ColorIndex = 6
End If

End Select
End If
Next
End Sub
 
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
Lookup missing number(s) in column w/blanks & duplicates Excel-User-RR Excel Worksheet Functions 3 February 20th 09 05:06 PM
Sumproduct copying blanks or how to insert zero into blanks asg2307 Excel Worksheet Functions 4 April 4th 07 07:26 PM
copy range of cells with blanks then paste without blanks justaguyfromky Excel Programming 5 September 3rd 06 11:23 PM
copy range of cells with blanks then paste without blanks justaguyfromky Excel Worksheet Functions 1 September 3rd 06 07:56 PM
Paste Special Skip Blanks not skipping blanks, but overwriting... gsrosin Excel Discussion (Misc queries) 0 February 22nd 05 03:33 AM


All times are GMT +1. The time now is 04:09 PM.

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

About Us

"It's about Microsoft Excel"