VBA "subscript out of range" error

beartooth91

New Member
Joined
Dec 15, 2024
Messages
44
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Probably an obvious mistake, but can't find the problem. The code below works....does what its supposed to do....splits and fills in all the values, but, at the end of the loop, I'm getting the "subscript out of range" error.


VBA Code:
Sub Fill_Sig_Type3()
'Using split string
Dim LastRow As Long, i As Long, StringArray() As String
With ActiveSheet
  
  LastRow = .Cells(Rows.Count, "B").End(xlUp).Row + 1
  For i = 8 To LastRow
    StringArray = Split(.Cells(i, "B"), "-", -1)
    
    .Cells(i, "E").Value = StringArray(1) '<----Getting 'subscript out of range' error at end of loop
  Next i
End With
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,225,287
Messages
6,184,076
Members
453,210
Latest member
GravyG_123

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