help noob with vba in excel

Gibson486

Lifer
Aug 9, 2000
18,378
1
0
I am not getting why this won't work. I keep getting an error saying that teh object does not support the method.

Sub THD()

a = 0
i = 3
r = "Results"

'iterate through sheets
'Do Until Sheets(i).Value = Sheets(i).r
Do Until Sheets(i).Value = "Results"<--------------------this causes errors, does it want an actual value? How do i make this dynamic?
Sheets(i).Select

'Select the range to copy in sheet
Range("C52:C56", "C63:C67").Select
Selection.Copy

'Activate Result sheet
Sheets(r).Select

'pick empty cell to paste results into

If Cells(a, 1).Value = "" Then
a = a + 1
ActiveCell.PasteSpecial


'if cell is not empty, iterate to next cell
Else
a = a + 1
Cells(a, 1).Select
ActiveCell.PasteSpecial

End If

'iterate to next sheet
i = i + 1
Loop


 

InfiniteLurker

Senior member
Mar 3, 2004
235
1
81
The error is due to the fact that the worksheet object does not have a Value property.

So, if you are looking to loop until you get to a worksheet that is named "Results", use the Name property.

Along the lines of:

Sub THD()
i = 1

Do Until Sheets(i).Name = "Results"
Sheets(i).Select
Range("C52:C56", "C63:C67").Select
i = i + 1
Loop

End Sub

Hope this helps...