I have produced a program and it is working perfectly. Now I just reproduced the same program but in a new spreadsheet where my complete program is kept but it is not working this time. I am getting this message:
Run-time error ‘9’
Subscript out of range
And this line is highlighted : Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 2
A small part of the program is as follow:
Private Sub Workbook_Open()
Sheet1.ComboBox 1.Clear
Sheet1.ComboBox 1.AddItem "Normal"
Sheet1.ComboBox 1.AddItem "1000 A"
Sheet1.ComboBox 1.AddItem "2000 A"
Sheet1.ComboBox 1.AddItem "5500 A"
End Sub
Option Explicit
Private Sub combobox1_chang e()
If ComboBox1 = "Normal" Then
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 2
ElseIf ComboBox1 = "1000 A" Then
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 0
ElseIf ComboBox1 = "2000 A" Then
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 1
Else
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 23
End if
End Sub
Because of this error my whole program is stopped. Could you please tell me how it can be solved?
Thanks and Regards,
Nasser.
Run-time error ‘9’
Subscript out of range
And this line is highlighted : Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 2
A small part of the program is as follow:
Private Sub Workbook_Open()
Sheet1.ComboBox 1.Clear
Sheet1.ComboBox 1.AddItem "Normal"
Sheet1.ComboBox 1.AddItem "1000 A"
Sheet1.ComboBox 1.AddItem "2000 A"
Sheet1.ComboBox 1.AddItem "5500 A"
End Sub
Option Explicit
Private Sub combobox1_chang e()
If ComboBox1 = "Normal" Then
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 2
ElseIf ComboBox1 = "1000 A" Then
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 0
ElseIf ComboBox1 = "2000 A" Then
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 1
Else
Sheets("sheet1" ).Shapes("recta ngle 8").Fill.ForeCo lor.SchemeColor = 23
End if
End Sub
Because of this error my whole program is stopped. Could you please tell me how it can be solved?
Thanks and Regards,
Nasser.