VBA "subscript out of range" error

beartooth91

Board Regular
Joined
Dec 15, 2024
Messages
69
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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,226,538
Messages
6,191,636
Members
453,668
Latest member
Stephen_Santos

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