• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

help noob with vba in excel

Gibson486

Lifer
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


 
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...
 
Back
Top