Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Loop Difficulty

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
smandula - 23 Mar 2006 01:33 GMT
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
Doug Glancy - 23 Mar 2006 03:41 GMT
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

>I have this code, where upon in B1 and C1 are  numbers entered such as
> 1, 1
[quoted text clipped - 34 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.