Does anyone no how to create a "for/next" loop that will compare specific cells in a specific worksheet. How do I reference the worksheet and the specific cell. The basic program was easy because the info was always in the program. This is gonna be a little more intrinsic I feel. Here's a sample of the normal loop I would use in basic, with the my dilenma about excel.
for a=1 to 5
if a=1 let b="specific worksheet/cell"
then the comparison
if b="specific worksheet/cell" let c=c+1
then dump the result
let "specific workshheet/cell =c
I think I'm going to have use "range" but perhaps some one can give me a clear macro, thanks
Jan 9, 2008, 3:16 pm
Is the following code a step in the right direction to compare specific cells across specific worksheets? (I didn't look closely at your logic for a,b, c; only referencing different worksheets/cells)
Sub Loop5() Dim i As Integer, ARef As String, BRef As String, CRef As String, c As Integer
For i = 1 To 5 ARef = "A" & CStr(i) 'Cstr() function converts integer to string BRef = "B" & CStr(i) 'you may want to change the variable referencing Sheet1 If Range("SheetX!" & ARef).Value = Range("Sheet1!B" & CStr(i) & "").Value Then c = c + 1 End If Next Debug.Print c End Sub