Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Subscript out of Range Error if Null
While redoing this function, (not very good i might add) I found out
that it only has the subscript error say if served = vntX(5) was empty, nothing was returned then it would give me the error, any way to fix that? also, could you show me a better shorter way to write this code jsut as an example.. Private Function SplitMe(strToSplit As String, intChoose As Integer) Dim vntX As Variant Dim First As String Dim last As String Dim mofa As String Dim child As String Dim issued As String Dim served As String vntX = Split(strToSplit, ",") First = vntX(0) last = vntX(1) mofa = vntX(2) child = vntX(3) issued = vntX(4) served = vntX(5) If intChoose = 0 Then SplitMe = First & "," & last ElseIf intChoose = 1 Then SplitMe = mofa ElseIf intChoose = 2 Then TxtFirstName = First TxtLastName = last CBOMoFa = mofa TxtIssued = issued TxtServed = served SplitMe = First & "," & last End If End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Subscript out of Range Error | Excel Programming | |||
Runtime Error - Subscript out of range despite On Error statement | Excel Programming | |||
Subscript out of range error - save copy error | Excel Programming | |||
Subscript out of range error - save copy error | Excel Programming | |||
Type Mismatch error & subscript out of range error | Excel Programming |