LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Trying to determine what cells within a Row have a 0 (zero) value

On Dec 17, 2:19*pm, Mike H wrote:
Hi,

I understand what your trying to do with endrange but not with startrange,
perhaps this will get you a bit further

Sub CreateNewSortRange()
Dim MyRange As Range
Dim StartRange As Variant
Dim EndRangeAdress As Variant
Set MyRange = Sheets("TestRange").Range("C5:c24")
For Each c In MyRange
* * If c.Value 0 And startRangeAddress = "" Then
* * * * startRangeAddress = c.Address
* * End If
* * If c.Value = 0 Then
* * * * EndRangeAddress = c.Address
* * Exit For
* * End If
Next
* * * * MsgBox "Range Start= " & startRangeAddress
* * * * MsgBox "Range End= " & EndRangeAddress
End Sub

Mike



"jparnold" wrote:
I'm new to programming and am trying to create code to read a row
cells 5 - 24 and determine what cell has a 0 value (The row is always
sorted by descending values). *So I want to read each cell starting
with C5 through the end of the range C24, and stop when it gets the
first 0 value. *Here is my code so far. *I don't get any errors, but
it deos not seem to be doing anything. *All Help is appreceated!


Sub CreateNewSortRange()


* Dim StartRange As Variant
* Dim EndRange As Variant
* Dim EndRangeAdress As Variant


* * Sheets("TestRange").Activate
* * Range("C5:c24").Select
* * Row = 3


* * For Col = 5 To 24


* * *With Worksheets("TestRange").Cells(Row, Col)


* * * * * * If ActiveCell.Value 0 Then
* * * * * * EndRangeAddress = ActiveCell.AddressLocal


* * * * * * If ActiveCell.Value = 0 Then
* * * * * * * * MsgBox "Range Start= " & StartRange
* * * * * * * * MsgBox "Range End= " & EndRangeAddress


* * * * * * End If
* * * * * *End If
* * * *End With
* * Next Col
.- Hide quoted text -


- Show quoted text -


Thats great! but I need to have EndRangeAddress be the last cell with
a non 0 value not the first 0 value cell.
 
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
Determine the distance between 2 cells in a column Ironhydroxide Excel Programming 0 January 7th 09 09:38 PM
A way to Determine visible cells on the page Mark Stephens Excel Programming 1 June 2nd 08 05:51 PM
What Excel function would you use to determine how many cells in a sean Excel Discussion (Misc queries) 0 February 1st 06 09:37 PM
Determine whether a value is in a range of cells Carl Excel Discussion (Misc queries) 2 December 12th 05 12:23 AM
Determine Selected Cells John Tripp[_2_] Excel Programming 2 July 31st 03 02:48 PM


All times are GMT +1. The time now is 01:31 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"