Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subscript out of Range Error BOBODD Excel Programming 0 December 14th 06 11:06 PM
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Subscript out of range error - save copy error bg18461[_16_] Excel Programming 2 June 13th 06 04:53 PM
Subscript out of range error - save copy error bg18461[_15_] Excel Programming 1 June 13th 06 04:36 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


All times are GMT +1. The time now is 06:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"