BaTy_GiRl
asked on
vba(excel) run time error 1004
hi there
i have 2 programs
i use the first one to test some code
and the second is the entire code
now my code works good at the first program the code is here (it only delete the rows which has 0 at column 2)
dec = 0
For I = 24 To 233
V = Sheet12.Cells(I, 2)
If V = "0" Then
Sheet12.Rows(I - dec).Select 'heres the problem
Selection.Delete shift:=lup
dec = dec + 1
End If
Next I
but when i paste the same code (i have the same object called sheet12 of course)
it says:
Run time error 1004
Select method of range class failed
:( please
i have 2 programs
i use the first one to test some code
and the second is the entire code
now my code works good at the first program the code is here (it only delete the rows which has 0 at column 2)
dec = 0
For I = 24 To 233
V = Sheet12.Cells(I, 2)
If V = "0" Then
Sheet12.Rows(I - dec).Select 'heres the problem
Selection.Delete shift:=lup
dec = dec + 1
End If
Next I
but when i paste the same code (i have the same object called sheet12 of course)
it says:
Run time error 1004
Select method of range class failed
:( please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think it gave that error just because the sheet wasn't selected. Say you had Sheet1 selected, and you gave it the command Sheet12.Range("A1").Select , it wouldn't know what to do because you didn't first say Sheet12.Select. It wasn't a problem with the object, just the selection portion of the code
ASKER
Thank you very much Matt you have solved my life =)
of course do you know why vba give that kind of errors, i was very confused because
in Visual basic those errors reference libraries when objects doesn`t exist