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: 620
Default counting a value within a range

Try this

myVal = Application.CountIf(Range(Selection, Selection.End(xlToRight)),
agentid)

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks


"auntie spam" wrote in message
...
hi all
i have a problem in counting a value within a selected range of cells
the value i do not know beforehand but the first instance of this value is
allways at a certain cell away from the selected cell
i want to count the number of times that this value appears within a range
and
then use this within a loop. this is the variable that i named agentId


this range is start and finish times each day for a week plus two cells
(16 cells) at the moment i am counting all the cells and then dividing

this
but
this value the agent id value does no appear all the time so this creates

an
error

i have at the moment

Range(Selection, Selection.End(xlToRight)).Select
numfull = Selection.Count

'want to get rid of this line and count the instances of agentId
agentIdCount = (numfull / 8) / 2

'selecting agentID
ActiveCell.Offset(0, 15).Range("A1").Select

'here i get the value that i am loking for
agentid = Selection.Value

'selecting week to cut
ActiveCell.Offset(0, 0).Range("A1:P1").Select
Selection.Cut

For clindex = 2 To agentIdCount + 1

'back home then down 1
Range("A1").Select
'expression.Offset(RowOffset, ColumnOffset)
Cells(clindex, 1).Select
''ActiveCell.Offset(1, 0).Range("A1").Select

ActiveSheet.Paste
Cells.Find(What:=agentid, After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,

_
MatchCase:=False).Activate

ActiveCell.Offset(0, 0).Range("A1:P1").Select
Selection.Cut
'Selection.Copy

Next clindex











 
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
Counting a range of cells OfficeManager Excel Worksheet Functions 2 July 16th 08 10:25 PM
counting range saman110 via OfficeKB.com Excel Discussion (Misc queries) 3 February 15th 08 05:32 AM
Counting from one range to another range, multiple criteria macamarr Excel Discussion (Misc queries) 3 June 10th 06 11:02 AM
Counting a range Blink Excel Worksheet Functions 3 August 25th 05 04:21 PM
counting a cell range within a range mmay321 Excel Worksheet Functions 2 August 10th 05 03:56 PM


All times are GMT +1. The time now is 06:32 AM.

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"