Hi All,
I have this for loop
For i = 2 To SheetNumber
If Sheets(i).Range("X2") = 2 Then
Dog = Dog + (Sheets(i).Range("F10").Value - Sheets(i).Range("B9").Value)
Counter = Counter + 1
End If
Next
sheets(1).range("B11").value = Dog
I am wondering if there was a way to change the variable Dog each time in the loop. I think i should be able to do this with an array but i cannot seem to get it. I believe my new code would look something like this.
Arr = Array("Dog","Cat","Mouse")
for j = LBound(Arr) to UBound(Arr)
For i = 2 To SheetNumber
If Sheets(i).Range("X2") = 2 Then
j = j + (Sheets(i).Range("F10").Value - Sheets(i).Range("B9").Value)
Counter = Counter + 1
End If
Next
Next
sheets(1).range("B11").value = Dog & " Dogs," & Cat & " Cats," & Mouse & " Mice."
I am not sure if it is something as simple as taking the "" out of the array or what. Is there some way to change a variable each time the for loop is run? Any help is appretiated. Thanks
Bookmarks