Cannot trace this simple error

S

Stuart

User has selected a folder, and I'm opening each file in the
folder in turn, working on it, leaving it open, and then opening
the next.
Whatever I try, I cannot get past the file "Vln 2 Barn 4.xls".

This sequence throws the error:... "The cell or chart you are
trying to change is protected, and therefore Read Only etc":

If C.Offset(0, 9).Value = "0" Then
C.Offset(0, 5).Value = Round(C.Value * C.Offset(0, 2).Value, 2)
ElseIf C.Offset(0, 9).Value = "5" Then
C.Offset(0, 6).Value = Round(C.Value * C.Offset(0, 2).Value, 2) ###
ElseIf C.Offset(0, 9).Value = "17.5" Then
C.Offset(0, 7).Value = Round(C.Value * C.Offset(0, 2).Value, 2)
End If
and the ### line is highlighted.

If I check each sheet, I find them all to be unprotected.

At this point variables in locals tells me that
C = D11
ws = Substructure 'the sheet being operated on
Actingonwkbk = "Vln 2 Barn 4.xls"

If I check D11, I find it empty/blank, and this is the same for
C.Offset(0, 9). However, if I hover over the code, then I'm
told that C.Offset(0, 9) = 5

I've used Format>Cells>Font>Automatic, but cannot see any values.

Can anyone help, please?

Regards.
 
K

Ken Wright

Any chance it could be referencing a hidden sheet in that file that may have
protection on it, and not the sheet you are looking at?
 
S

Stuart

Thanks but no sheets appear to be hidden. I've copied that book
to a new folder and run the code on it alone, with no problem. So...

Will post back if I can't isolate the problem.

Regards.




I'm going to copy it into a new folder and
 
S

Stuart

Right, I've run the code on each book from that original folder.
By that, I mean by copying each book into an empty folder
and running the code in turn.
Each book ran well past that original problem, including
therefore the problem book.

Problem is that this routine is designed to calculate Value
Added Tax (three different rates, sometimes more), so I
guess Customs & Excise would be pleased if I got it right
first time, rather than after they call on me!

Regards.
 
P

Paul Robinson

Hi Stuart
Sounds like your problem has more to do with your looping through
workbooks then. Can you show us that code? It may be that a sprinkling
of "Do Events" might fix your problem.
regards
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top