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: 573
Default Next w/o For?

I'm working on a macro that searches for text in certain cells and
counts the number if times it finds those text values. So far, I've
got:

Sub CountReasonContactCode()
Dim Wksht As Worksheet
Dim rReason As Range
Dim lRow As Long
Dim lCurRow As Long
Dim rCell As Range
Dim l16Rct As Long
Dim l16Act As Long
Dim l16BGct As Long
Dim lCt As Long


lRow = 107

l16Rct = 0
l16Act = 0
l16BGct = 0
Set rReason = ActiveSheet.Range("D8", Cells(lRow, "D"))
rReason.Select

For Each rCell In rReason
If rCell = "16" Then

lCt = InStr(1, rCell.Offset(0, 2).Value, "R")
If lCt 0 Then
l16Rct = l16Rct + 1
lCt = 0
lCt = InStr(1, rCell.Offset(0, 2).Value, "A")
If lCt 0 Then
l16Act = l16Act + 1
lCt = 0
lCt = InStr(1, rCell.Offset(0, 2).Value, "B")
If lCt 0 Then
l16BGct = l16BGct + 1
lCt = 0

End If
Next rCell

End Sub

Getting a compile error, "Next without for". I see a next and a for, so
can't figure out why XL isn't seeing it. What am I missing?
Thanks in advance.

 
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



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