Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Help getting code to work.

I didn't run the code but what popped out at me was no end
if after the if's in the code. try adding that?
-----Original Message-----
With my limited knowledge and abilities I tried to modify

some code I was already using. But when I changed it, it
stoped working properly. I am trying to compare lists of
names in rows in sheet1 to a list in a column in sheet2
and return the count of how many of the names in each row
in sheet1 are in the list in sheet2 and how many are not
in the list. Also I want the total count of individual
names in each row in sheet1. It almost works, but it gets
stuck in a loop. Below is what I have muddled through.
If anyone has any suggestions, I would really appreciate
them.
Erik
Private Sub Worksheet_Change(ByVal Target As Range)
Dim aNames As Collection
Dim bNames As Collection
Dim c As Range
Dim rng As Range
Dim iCt As Integer
Dim iRow As Integer
Dim Ct As Integer


On Error Resume Next

For iRow = 3 To 37 Step 2
Set aNames = New Collection
Set bNames = New Collection
Set rng = Sheets("sheet1").Range("G" & iRow

& ":CI" & iRow)
For Each c In rng
Debug.Print c.Address
For Ct = 1 To 18
If c.Value = Sheets("sheet2").Cells(Ct + 4,

10) Then aNames.Add c.Value, c.Value
Next Ct
If aNames.Count = 0 Then bNames.Add c.Value,

c.Value
Next c

Sheets("sheet1").Cells(iRow - 1, 4) = aNames.Count
Sheets("sheet1").Cells(iRow, 4) = bNames.Count
Sheets("sheet3").Cells((iRow - 1) / 2 + 4, 6) =

aNames.Count + bNames.Count

Set aNames = Nothing
Set bNames = Nothing

Next iRow

End Sub

.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Help getting code to work.

If that were a problem, it wouldn't compile. I think he's using single-line IF
statements -- they are just wrapping in the message.

I thought he implied it goes into a [endless] loop, and I can't see why. His 3
loops are all For/Next, and each has a finite ending point (row 37, 81 cells
in a row on sheet1 (G:CI), column 18). I wonder if, because of the use of
collections, it is just very slow and he *thinks* it's in a loop.



On Wed, 28 Jul 2004 10:51:25 -0700, "Frank Stone"
wrote:

I didn't run the code but what popped out at me was no end
if after the if's in the code. try adding that?
-----Original Message-----
With my limited knowledge and abilities I tried to modify

some code I was already using. But when I changed it, it
stoped working properly. I am trying to compare lists of
names in rows in sheet1 to a list in a column in sheet2
and return the count of how many of the names in each row
in sheet1 are in the list in sheet2 and how many are not
in the list. Also I want the total count of individual
names in each row in sheet1. It almost works, but it gets
stuck in a loop. Below is what I have muddled through.
If anyone has any suggestions, I would really appreciate
them.
Erik
Private Sub Worksheet_Change(ByVal Target As Range)
Dim aNames As Collection
Dim bNames As Collection
Dim c As Range
Dim rng As Range
Dim iCt As Integer
Dim iRow As Integer
Dim Ct As Integer


On Error Resume Next

For iRow = 3 To 37 Step 2
Set aNames = New Collection
Set bNames = New Collection
Set rng = Sheets("sheet1").Range("G" & iRow

& ":CI" & iRow)
For Each c In rng
Debug.Print c.Address
For Ct = 1 To 18
If c.Value = Sheets("sheet2").Cells(Ct + 4,

10) Then aNames.Add c.Value, c.Value
Next Ct
If aNames.Count = 0 Then bNames.Add c.Value,

c.Value
Next c

Sheets("sheet1").Cells(iRow - 1, 4) = aNames.Count
Sheets("sheet1").Cells(iRow, 4) = bNames.Count
Sheets("sheet3").Cells((iRow - 1) / 2 + 4, 6) =

aNames.Count + bNames.Count

Set aNames = Nothing
Set bNames = Nothing

Next iRow

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
Why does this code not work? rk0909 Excel Discussion (Misc queries) 12 September 4th 08 10:42 PM
Why this code is not work? Error code when select worksheet Excel Worksheet Functions 4 December 4th 07 12:51 AM
Code won't work? Joe 90 Excel Programming 3 October 2nd 03 04:26 AM
Why my code do not work : - ( keepitcool Excel Programming 5 September 5th 03 06:28 PM
Why my code do not work : - ( Bob Phillips[_5_] Excel Programming 0 August 31st 03 01:27 PM


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