Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Loop Difficulty

I have this code, where upon in B1 and C1 are numbers entered such as
1, 1
Line code:
--- Sheet1.Range("B1").Value = Sheet1.Range("B1").Value + 1
increases 1,1 to 2,1 to 3,1 .. etc. which is OK
However, This Line of Code stays static and does not increase
---- Range("AQ3").Value = Count

Question is how can "AQ3" increase as "B1" increases? So 2,1 would be
"AQ4",
and 3,1 would be "AQ5" .. etc.
----------------------------------------------------------------
Code
Sub GetCountNow()
Dim No1 As Single
Dim No2 As Single
Dim NumberOfRows As Single
Dim RowRange As Range
Dim Count As Single
Dim Counter As Integer
No1 = [B1]
No2 = [C1]
NumberOfRows = Range("B3", Range("B" & Rows.Count). _
End(xlUp).Address).Rows.Count
Count = 0
Set RowRange = Range("B3", "AN3")
For Counter = 1 To NumberOfRows
If Not (RowRange.Find(What:=No1, LookAt:=xlWhole) Is Nothing) =
True And _
Not (RowRange.Find(What:=No2, LookAt:=xlWhole) Is Nothing)
= True Then _
Count = Count + 1
Set RowRange = RowRange.Offset(1)
Next
Range("AQ3").Value = Count
Sheet1.Range("B1").Value = Sheet1.Range("B1").Value + 1

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Loop Difficulty

smandula,

I'm not sure, but it might help to qualify all your ranges, like you did
with some, e.g.:

Sheet1.Range("AQ3").Value = Count

hth,

Doug


"smandula" wrote in message
ups.com...
I have this code, where upon in B1 and C1 are numbers entered such as
1, 1
Line code:
--- Sheet1.Range("B1").Value = Sheet1.Range("B1").Value + 1
increases 1,1 to 2,1 to 3,1 .. etc. which is OK
However, This Line of Code stays static and does not increase
---- Range("AQ3").Value = Count

Question is how can "AQ3" increase as "B1" increases? So 2,1 would be
"AQ4",
and 3,1 would be "AQ5" .. etc.
----------------------------------------------------------------
Code
Sub GetCountNow()
Dim No1 As Single
Dim No2 As Single
Dim NumberOfRows As Single
Dim RowRange As Range
Dim Count As Single
Dim Counter As Integer
No1 = [B1]
No2 = [C1]
NumberOfRows = Range("B3", Range("B" & Rows.Count). _
End(xlUp).Address).Rows.Count
Count = 0
Set RowRange = Range("B3", "AN3")
For Counter = 1 To NumberOfRows
If Not (RowRange.Find(What:=No1, LookAt:=xlWhole) Is Nothing) =
True And _
Not (RowRange.Find(What:=No2, LookAt:=xlWhole) Is Nothing)
= True Then _
Count = Count + 1
Set RowRange = RowRange.Offset(1)
Next
Range("AQ3").Value = Count
Sheet1.Range("B1").Value = Sheet1.Range("B1").Value + 1

End Sub



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
Difficulty with Sum+IF Function Gmania-1980 Excel Worksheet Functions 10 October 27th 09 07:49 PM
Function Difficulty Johnnie[_2_] Excel Discussion (Misc queries) 5 October 20th 08 09:54 PM
Calling Sub difficulty Giselle[_2_] Excel Programming 5 February 5th 06 10:16 PM
Difficulty with MOD operator when using Mod 1 Terry Holmes Excel Programming 5 April 27th 05 09:52 PM
AutoFill difficulty Jim Berglund Excel Programming 3 November 10th 04 11:24 PM


All times are GMT +1. The time now is 12:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"