Subscript out of range and type mismatch errors

fun4all

New Member
Joined
Jun 17, 2012
Messages
19
Hello,

I am having trouble with the following code:

Code:
Private Sub CODE_Change()

Dim ws As Worksheet
Dim fm As Worksheet
Set ws = Worksheets(ActiveSheet.Name)
Set fm = Worksheets("Form")

Dim range0 As Range, res As Variant
Set range0 = Worksheets(ActiveSheet.Name).Range("A1:P1000").Columns(1)
res = Application.Match(CODE.Text, range0, 0)

If Not IsError(res) Then

Set range1 = range0.Cells(res, 1)

AddData.Enabled = False
EditData.Enabled = True
CheckBox1.Enabled = False
PROJECT.Text = range1.offset(0, 1)
COMPONENT.Text = range1.offset(0, 3)
CRITERIA.Text = range1.offset(0, 4)
ITEM.Text = range1.offset(0, 2)
DEVELOPERNAME.Text = range1.offset(0, 9)
NUMBOARDS.Text = range1.offset(0, 5)
VENDOR.Text = range1.offset(0, 7)
PLANT.Text = range1.offset(0, 8)

[COLOR=#ff0000]InnerColor.Text = Trim(Split(Trim(Split(range1.offset(0, 9).[COLOR=#ff0000]Text[/COLOR], ";")(1)), ":")(1))
OuterColor.[COLOR=#ff0000]Text[/COLOR] = Trim(Split(Trim(Split(range1.offset(0, 9).[COLOR=#ff0000]Text[/COLOR], ";")(0)), ":")(1))
[/COLOR]
Else

AddData.Enabled = True
EditData.Enabled = False
CheckBox1.Enabled = True

End If
SendEmail.Enabled = False
SaveForm.Enabled = False

End Sub


I get a subscript out of range error for the lines marked in red (InnerColor and OuterColor). When I remove the (1)s and (0)s or change .text to .value, I get a type mismatch error.

Help is much appreciated. Thank you in advance!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,206,920
Messages
6,075,573
Members
446,147
Latest member
homedecortips

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top