0

Here is my code,

If ActiveWorkbook.Sheets("About tool").Range("G1").Value = 1 Then
    ActiveWorkbook.Sheets("About tool").Range("G1").Value = 0

    With ActiveWorkbook.Sheets("About tool").Shapes("Rounded Rectangle 2").TextFrame2
        If .HasText Then
            .TextRange.Delete
            .TextRange.Text = "Unlock All"
        End If
    End With

ElseIf ActiveWorkbook.Sheets("About tool").Range("G1").Value = 0 Then
        ActiveWorkbook.Sheets("About this tool ").Range("G1").Value = 1

        With ActiveWorkbook.Sheets("About tool").Shapes("Rounded Rectangle 2").TextFrame2
            If .HasText Then
                .TextRange.Delete
                .TextRange.Text = "Lock All"
            End If
        End With    
End If

Here on the ELSEIF section, I am getting an error saying "runtime error -2147024809 (80070057) the specified value is out of range".

It is working fine in the IF section. it is the same code with just change in the string passed as text.

Community
  • 1
  • 1
srt
  • 521
  • 3
  • 11
  • 22
  • The error occurs on a specific line. Which line is it that it breaks on? – JNevill Jun 20 '18 at 14:23
  • @JNevill The error was occurring on ".TextRange.Delete". I have figured it out. The answer is below. Thanks anyway. – srt Jun 20 '18 at 14:46

1 Answers1

0

Sry, for wasting your time to click on this question.

It's just that, I was trying to edit the text of the shape when the sheet was protected. which is the cause for the error.

Should have read through the below link earlier.

Microsoft Excel VBA - Run-Time Error '-2147024809 (80070057)'

srt
  • 521
  • 3
  • 11
  • 22