Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Select every cell that has a certain value

I want to select every cell in an orderd column that has value 0. Is this
possible and how would you do it? First I search the spreadsheet in order to
find the cell that signals the start of the list. The code is:

Set relativCell = Worksheets("Beräkning").Cells.Find("Rel.", LookIn:=xlValues)

I then want to search through every value below relativCell and see if they
are equal to zero. I have ensured that it is a ordered list so you really
just need the first and the last cell that is equal to zero. I search through
the list like this:

Do Until IsEmpty(relativCell.Offset(i, 0)) = True
i = i + 1 'längst ner i listan
Loop

Can someone please help me with how you find the range for the zero values?
what i want to do is to give the user the opportunity to hide all rows that
has value equal to zero.. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Select every cell that has a certain value

Just use find and FindNext, something like this...

Sub FindZero()
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim strFirstAddress As String

Set wks = Sheets("Beräkning")
Set rngToSearch = wks.Cells
Set rngFound = rngToSearch.Find(What:=0, _
LookIn:=xlValues, _
LookAt:=xlWhole)
If Not rngFound Is Nothing Then
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.select
End If
End Sub


--
HTH...

Jim Thomlinson


"Arne Hegefors" wrote:

I want to select every cell in an orderd column that has value 0. Is this
possible and how would you do it? First I search the spreadsheet in order to
find the cell that signals the start of the list. The code is:

Set relativCell = Worksheets("Beräkning").Cells.Find("Rel.", LookIn:=xlValues)

I then want to search through every value below relativCell and see if they
are equal to zero. I have ensured that it is a ordered list so you really
just need the first and the last cell that is equal to zero. I search through
the list like this:

Do Until IsEmpty(relativCell.Offset(i, 0)) = True
i = i + 1 'längst ner i listan
Loop

Can someone please help me with how you find the range for the zero values?
what i want to do is to give the user the opportunity to hide all rows that
has value equal to zero.. Thanks!

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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
How to point to (select) a cell to the left from a cell where I enter the = equal sign? Dmitry Excel Discussion (Misc queries) 4 June 30th 06 06:49 AM
I cannot select a single cell or pull down cell contents Carolyn Fahm Excel Worksheet Functions 0 January 24th 06 04:54 PM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM


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