Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Please Help Splitting data

See the inline code addition and my comment at the end...

MyVariable = Trim(Mid(data, (InStr(data, ",") - 1)))\

This is the string in wich im trying to Take the date out of,
secondname,thirdname,Mother:1,childname,10/12/2007,

However sometimes it might look like this depending on user input
secondname,thirdname,Mother:1,childname,10/12/2007,10/14/2007

i need Txtbox 1 = the first date, and TxtBox 2 = SecondDate

Here is The Function as is, I asked last week on here but am still
having trouble changing it.

Private Function getfields(data As String, intchoose As Integer) As
String
Dim firstdate As String
Dim seconddate As String
Dim vntX As Variant

vntX = Split(data, ",")

If intchoose = 0 Then
getfields = vntX(0) & "," & vntX(1) ' First Name Last Name
ElseIf intchoose = 2 Then
getfields = vntX(2) ' TxtBox6
ElseIf intchoose = 1 Then
TxtFirstName = vntX(0) ' TxtBox1
TxtLastName = vntX(1) ' TxtBox2
CBOMoFa = vntX(2) ' TxtBox6
TxtChild = vntX(3) ' TxtBox4


Txt3 = vntX(4)
Txt5 = vntX(5)

End If
End Function
TxtBox 3 and 5 are the dates Txt3 is date 1 Txt5 is date 2


Note that the the assignment to Txt5 assumes the trailing comma is present
(as shown in your sample data) when there is only one included date.

Rick

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Please Help Splitting data

On Mon, 10 Dec 2007 16:19:55 -0500, "Rick Rothstein \(MVP - VB\)"
wrote:

See the inline code addition and my comment at the end...

MyVariable = Trim(Mid(data, (InStr(data, ",") - 1)))\

This is the string in wich im trying to Take the date out of,
secondname,thirdname,Mother:1,childname,10/12/2007,

However sometimes it might look like this depending on user input
secondname,thirdname,Mother:1,childname,10/12/2007,10/14/2007

i need Txtbox 1 = the first date, and TxtBox 2 = SecondDate

Here is The Function as is, I asked last week on here but am still
having trouble changing it.

Private Function getfields(data As String, intchoose As Integer) As
String
Dim firstdate As String
Dim seconddate As String
Dim vntX As Variant

vntX = Split(data, ",")

If intchoose = 0 Then
getfields = vntX(0) & "," & vntX(1) ' First Name Last Name
ElseIf intchoose = 2 Then
getfields = vntX(2) ' TxtBox6
ElseIf intchoose = 1 Then
TxtFirstName = vntX(0) ' TxtBox1
TxtLastName = vntX(1) ' TxtBox2
CBOMoFa = vntX(2) ' TxtBox6
TxtChild = vntX(3) ' TxtBox4


Txt3 = vntX(4)
Txt5 = vntX(5)

End If
End Function
TxtBox 3 and 5 are the dates Txt3 is date 1 Txt5 is date 2


Note that the the assignment to Txt5 assumes the trailing comma is present
(as shown in your sample data) when there is only one included date.

Rick


Much simpler than mine. I didn't read the OP's code carefully before
fabricating my recommendation.
--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Please Help Splitting data


"Ron Rosenfeld" wrote in message
...
On Mon, 10 Dec 2007 16:19:55 -0500, "Rick Rothstein \(MVP - VB\)"
wrote:

See the inline code addition and my comment at the end...

MyVariable = Trim(Mid(data, (InStr(data, ",") - 1)))\

This is the string in wich im trying to Take the date out of,
secondname,thirdname,Mother:1,childname,10/12/2007,

However sometimes it might look like this depending on user input
secondname,thirdname,Mother:1,childname,10/12/2007,10/14/2007

i need Txtbox 1 = the first date, and TxtBox 2 = SecondDate

Here is The Function as is, I asked last week on here but am still
having trouble changing it.

Private Function getfields(data As String, intchoose As Integer) As
String
Dim firstdate As String
Dim seconddate As String
Dim vntX As Variant

vntX = Split(data, ",")

If intchoose = 0 Then
getfields = vntX(0) & "," & vntX(1) ' First Name Last Name
ElseIf intchoose = 2 Then
getfields = vntX(2) ' TxtBox6
ElseIf intchoose = 1 Then
TxtFirstName = vntX(0) ' TxtBox1
TxtLastName = vntX(1) ' TxtBox2
CBOMoFa = vntX(2) ' TxtBox6
TxtChild = vntX(3) ' TxtBox4


Txt3 = vntX(4)
Txt5 = vntX(5)

End If
End Function
TxtBox 3 and 5 are the dates Txt3 is date 1 Txt5 is date 2


Note that the the assignment to Txt5 assumes the trailing comma is present
(as shown in your sample data) when there is only one included date.

Rick


Much simpler than mine. I didn't read the OP's code carefully before
fabricating my recommendation.
--ron


The "hammer/nail" thing again, huh? <vbg

Rick

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
data splitting ernietan Excel Discussion (Misc queries) 1 April 20th 10 10:40 AM
Splitting Data Nicole Excel Worksheet Functions 2 December 4th 08 10:07 PM
splitting data Windy Excel Discussion (Misc queries) 1 January 23rd 08 02:28 AM
Splitting a Column of Data into Two Columns of Data [email protected] Excel Programming 0 May 24th 07 11:00 PM
Splitting Data jez123456 Excel Worksheet Functions 4 March 4th 05 09:38 AM


All times are GMT +1. The time now is 03:58 AM.

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

About Us

"It's about Microsoft Excel"