Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to return multiple cells?

OKLover

It will find the first cell with a 0 after Q3
aCell.address will give you the cell

If you want to have a range with all 0 values you can use Union
Example for A1:A100

Sub UnionExample()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
Dim rng As Range

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 100
For Lrow = StartRow To EndRow Step 1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell
ElseIf .Cells(Lrow, "A").Value = "0" Then
If rng Is Nothing Then
Set rng = .Cells(Lrow, "A")
Else
Set rng = Application.Union(rng, .Cells(Lrow, "A"))
End If
End If
Next
End With

'Select all rows with a 0
If Not rng Is Nothing Then
rng.Select
MsgBox rng.Address
End If

With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"OKLover" wrote in message ...
The code as below:

Set fCell = Columns("Q:Q").Cells
Set aCell = fCell.Find(What:=0, LookIn:=xlValues, After:=Range("Q3"), _
SearchOrder:=xlByColumns)
MsgBox aCell.Cells.Count

If there are more than one cell are 0 value, The Msgbox always return 1.
What i can do? so it may be return the range which cell contain 0 value.

Many 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
Return true if multiple cells are the same linglc Excel Discussion (Misc queries) 3 April 2nd 23 08:39 PM
Setting multiple conditions to return a figure from multiple cells Sapper Excel Discussion (Misc queries) 4 April 26th 09 10:33 PM
lookup across multiple sheets & return sum of cells se7098 Excel Worksheet Functions 5 October 17th 08 10:10 PM
Function evaluate multiple cells and return 1st one w/a value Dan Shoemaker Excel Discussion (Misc queries) 1 August 27th 06 02:46 AM
Return data from multiple cells Redleg40 Excel Worksheet Functions 1 July 19th 05 03:40 PM


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