ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runtime Error 1004 (https://www.excelbanter.com/excel-programming/277073-runtime-error-1004-a.html)

Don[_7_]

Runtime Error 1004
 
Further, if I remove the dot before the
Range("L2").Select
It works, but not necessaarily on the right sheet.


-----Original Message-----
My worksheets are protected with UserModeOnly = True

I have a piece of code

With Worksheets(MySheet)
.Cells.Select
.Paste
Application.CutCopyMode = False
.Range("L4").Select
.Range("J2,L2,L4").Select
Selection.Replace _
What:="Sheet1", _
Replacement:=LinkTo, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
.Range("L2").Select
.Move Befo=Sheets(1)
End With

It stops on the
..Range("L2").Select
with a Runtime Error 1004 - Protected and Read Only.
BUt this cell is unlocked.

If I move the
..Range("L4").Select
before the
..Range("L2").Select
it stops there insttead.

If I move the
..Range("L2").Select
before the
..Range("J2,L2,L4").Select
it works, but not with the required behaviour.

Can anyone tell me why it's stopping on a Range.Select ?
Will a Cell.Select work where a Range.Select will mot ?

Thanks,

Don.

.


Tom Ogilvy

Runtime Error 1004
 
Why do you need to select L2 or L4 by themselves.

With Worksheets(MySheet)
.Cells.Select
.Paste
Application.CutCopyMode = False
.Range("J2,L2,L4").Replace _
What:="Sheet1", _
Replacement:=LinkTo, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
.Move Befo=Sheets(1)
End With

Should still work the way you want it to.

--
Regards,
Tom Ogilvy


"Don" wrote in message
...
Further, if I remove the dot before the
Range("L2").Select
It works, but not necessaarily on the right sheet.


-----Original Message-----
My worksheets are protected with UserModeOnly = True

I have a piece of code

With Worksheets(MySheet)
.Cells.Select
.Paste
Application.CutCopyMode = False
.Range("L4").Select
.Range("J2,L2,L4").Select
Selection.Replace _
What:="Sheet1", _
Replacement:=LinkTo, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
.Range("L2").Select
.Move Befo=Sheets(1)
End With

It stops on the
..Range("L2").Select
with a Runtime Error 1004 - Protected and Read Only.
BUt this cell is unlocked.

If I move the
..Range("L4").Select
before the
..Range("L2").Select
it stops there insttead.

If I move the
..Range("L2").Select
before the
..Range("J2,L2,L4").Select
it works, but not with the required behaviour.

Can anyone tell me why it's stopping on a Range.Select ?
Will a Cell.Select work where a Range.Select will mot ?

Thanks,

Don.

.




Don[_7_]

Runtime Error 1004 - Cell Protected aqnd Read Only
 
Thanks Tom

The only reason I do any of this is beacause of a bug that
prevents me from Copying more than 3 sheets in a Session,
but the issue is not the Replace, it's the fact that
things don't work even though I have UserModeOnly enabled.

I even have a routine that invokes UserModeOnly in every
Sub as a workaround to another bug.

Don.

-----Original Message-----
Why do you need to select L2 or L4 by themselves.

With Worksheets(MySheet)
.Cells.Select
.Paste
Application.CutCopyMode = False
.Range("J2,L2,L4").Replace _
What:="Sheet1", _
Replacement:=LinkTo, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
.Move Befo=Sheets(1)
End With

Should still work the way you want it to.

--
Regards,
Tom Ogilvy


"Don" wrote in message
...
Further, if I remove the dot before the
Range("L2").Select
It works, but not necessaarily on the right sheet.


-----Original Message-----
My worksheets are protected with UserModeOnly = True

I have a piece of code

With Worksheets(MySheet)
.Cells.Select
.Paste
Application.CutCopyMode = False
.Range("L4").Select
.Range("J2,L2,L4").Select
Selection.Replace _
What:="Sheet1", _
Replacement:=LinkTo, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
.Range("L2").Select
.Move Befo=Sheets(1)
End With

It stops on the
..Range("L2").Select
with a Runtime Error 1004 - Protected and Read Only.
BUt this cell is unlocked.

If I move the
..Range("L4").Select
before the
..Range("L2").Select
it stops there insttead.

If I move the
..Range("L2").Select
before the
..Range("J2,L2,L4").Select
it works, but not with the required behaviour.

Can anyone tell me why it's stopping on a

Range.Select ?
Will a Cell.Select work where a Range.Select will mot ?

Thanks,

Don.

.



.



All times are GMT +1. The time now is 04:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com