Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Count Cells in Range

I have a named range (non contiguous cells) going down several columns called
BidCatNum. Most of these cells contain the letter "Y". For each cell that
contains the letter "Y", I want to write code to perform an action on the
cell immediately to the right of it.

I'm not too experienced with the "For each cell in this range, do this"
lingo. Could someone get me started? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Count Cells in Range

Sub ProcessBidCatNum()
Dim cell as Range, cell1 as Range
for each cell in Range("BidCatNum")
if lcase(cell.value) = "y" then
set cell1 = cell.offset(0,1)
' perform action using cell1
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"Steve C" wrote in message
...
I have a named range (non contiguous cells) going down several columns

called
BidCatNum. Most of these cells contain the letter "Y". For each cell

that
contains the letter "Y", I want to write code to perform an action on the
cell immediately to the right of it.

I'm not too experienced with the "For each cell in this range, do this"
lingo. Could someone get me started? Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Count Cells in Range

This should be close...

Sub DoStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim strFirstAddress As String

Set rngToSearch = Range("BidCatNum")
Set rngFound = rngToSearch.Find(What:="Y", _
LookIn:=xlValues, _
LookAt:=xlWhole)
If Not rngFound Is Nothing Then
strFirstAddress = rngFound.Address
Do
Call ChangeStuff(rngFound.Offset(0, 1))
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
End If

End Sub

Sub ChangeStuff(ByVal Target As Range)
MsgBox Target.Address
End Sub

--
HTH...

Jim Thomlinson


"Steve C" wrote:

I have a named range (non contiguous cells) going down several columns called
BidCatNum. Most of these cells contain the letter "Y". For each cell that
contains the letter "Y", I want to write code to perform an action on the
cell immediately to the right of it.

I'm not too experienced with the "For each cell in this range, do this"
lingo. Could someone get me started? Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Count Cells in Range

Tom & Jim: Thanks a ton!


"Jim Thomlinson" wrote:

This should be close...

Sub DoStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim strFirstAddress As String

Set rngToSearch = Range("BidCatNum")
Set rngFound = rngToSearch.Find(What:="Y", _
LookIn:=xlValues, _
LookAt:=xlWhole)
If Not rngFound Is Nothing Then
strFirstAddress = rngFound.Address
Do
Call ChangeStuff(rngFound.Offset(0, 1))
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
End If

End Sub

Sub ChangeStuff(ByVal Target As Range)
MsgBox Target.Address
End Sub

--
HTH...

Jim Thomlinson


"Steve C" wrote:

I have a named range (non contiguous cells) going down several columns called
BidCatNum. Most of these cells contain the letter "Y". For each cell that
contains the letter "Y", I want to write code to perform an action on the
cell immediately to the right of it.

I'm not too experienced with the "For each cell in this range, do this"
lingo. Could someone get me started? 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
Count cells in a range Otto Moehrbach[_2_] Excel Discussion (Misc queries) 2 July 20th 09 05:11 PM
Count a range of cells using an IF Access Joe Excel Worksheet Functions 9 July 31st 08 12:26 AM
Count Certain Cells in Specified Range Xavier Excel Worksheet Functions 3 July 25th 06 10:25 PM
count cells in a range fullers Excel Worksheet Functions 2 November 30th 05 01:36 PM
Count cells in one range based on parameters in another range dave roth Excel Worksheet Functions 2 March 29th 05 05:33 PM


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