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: 117
Default Need a bit of help on comparing cells

Hi there, I have cobbled together the code below, it is supposed to
compare
the cell values of each row on 56 sheets by comparing it with the data
on
a sheet named 'Datasheet'...The data on the 'Datasheet' is 427 rows
deep but
will be added to sooner or later... I can get it to count the hits,
but it
only does that for the first line..I can't get it to check the other
426 rows
to give the total amount of hits over all 427+ lines...

any help is greatly appreciated...

ste

Option Explicit
Sub howmanyhits()
Dim sheetname As String
Dim sheetnumber As Long

For sheetnumber = 1 To 56

sheetname = "S" & Format(sheetnumber, "##0")
Sheets(sheetname).Select

howmanylinehits

Next
Application.ScreenUpdating = False
End Sub

Sub howmanylinehits()
Dim xlrow As Long
Dim data1 As Long
Dim data2 As Long
Dim data3 As Long
Dim data4 As Long
Dim data5 As Long
Dim datatotal As Long
Dim b1 As Range
Dim b2 As Range
Dim b3 As Range
Dim b4 As Range
Dim b5 As Range
Dim sheetnumber As Long

Set b1 = Sheets("Datasheet").Range("B3")
Set b2 = Sheets("Datasheet").Range("C3")
Set b3 = Sheets("Datasheet").Range("D3")
Set b4 = Sheets("Datasheet").Range("E3")
Set b5 = Sheets("Datasheet").Range("F3")

Application.ScreenUpdating = False
xlrow = 2

Do While Not (ActiveSheet.Cells(xlrow, 1).Value = "")
If ActiveSheet.Cells(xlrow, 3).Value = b1 Then
data1 = 1
Else: data1 = 0
End If
If ActiveSheet.Cells(xlrow, 4).Value = b2 Then
data2 = 1
Else: data2 = 0
End If
If ActiveSheet.Cells(xlrow, 5).Value = b3 Then
data3 = 1
Else: data3 = 0
End If
If ActiveSheet.Cells(xlrow, 6).Value = b4 Then
data4 = 1
Else: data4 = 0
End If
If ActiveSheet.Cells(xlrow, 7).Value = b5 Then
data5 = 1
Else: data5 = 0
End If
datatotal = data1 + data2 + data3 + data4 + data5
If datatotal = 0 Then
ActiveSheet.Cells(xlrow, 8).Value = ActiveSheet.Cells(xlrow, 8).Value
+ 1
ElseIf datatotal = 1 Then
ActiveSheet.Cells(xlrow, 9).Value = ActiveSheet.Cells(xlrow, 9).Value
+ 1
ElseIf datatotal = 2 Then
ActiveSheet.Cells(xlrow, 10).Value = ActiveSheet.Cells(xlrow,
10).Value + 1
ElseIf datatotal = 3 Then
ActiveSheet.Cells(xlrow, 11).Value = ActiveSheet.Cells(xlrow,
11).Value + 1
ElseIf datatotal = 4 Then
ActiveSheet.Cells(xlrow, 12).Value = ActiveSheet.Cells(xlrow,
12).Value + 1
ElseIf datatotal = 5 Then
ActiveSheet.Cells(xlrow, 13).Value = ActiveSheet.Cells(xlrow,
13).Value + 1
End If
ActiveSheet.Cells(xlrow, 14).Value = ActiveSheet.Cells(xlrow,
13).Value + ActiveSheet.Cells(xlrow, 12).Value _
+ ActiveSheet.Cells(xlrow, 11).Value + ActiveSheet.Cells(xlrow,
10).Value + ActiveSheet.Cells(xlrow, 9).Value
xlrow = xlrow + 1

Set b1 = b1.Offset(1, 0)
Set b2 = b2.Offset(1, 0)
Set b3 = b3.Offset(1, 0)
Set b4 = b4.Offset(1, 0)
Set b5 = b5.Offset(1, 0)

Application.StatusBar = xlrow & sheetnumber
Loop
Application.StatusBar = False

End Sub
 
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
Comparing Cells basic Excel Discussion (Misc queries) 1 August 20th 09 08:37 PM
Need Help Comparing Cells Matt H Excel Discussion (Misc queries) 4 May 3rd 08 05:24 AM
Comparing cells when they are not exactly the same Garry Excel Discussion (Misc queries) 2 April 2nd 07 10:26 AM
comparing cells Nooby Excel Discussion (Misc queries) 3 May 19th 06 06:52 PM
comparing cells Help me Excel Worksheet Functions 1 May 9th 06 10:01 PM


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