Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Splitting out text in VBA

Hi everyone. I have a cell that contains multiple values, separated by commas. What I would like to do is split out the text data based on the comma. So let's say that my cell contains the following: Red, Blu

This is my code
Text_Array = Split(CurrentCell,Chr(44)
MsgBox Text_Array(0
MsgBox Text_Array(1

So I would expect to see two message boxes, the first one to say Red, the second to say Blue. But when I do this, I get an error message that says "Subscript out of range". Is there something that I am doing wrong

Thanks
Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Splitting out text in VBA

Replace "CurrentCell" with "ActiveCell".

-Brad
-----Original Message-----
Hi everyone. I have a cell that contains multiple values,

separated by commas. What I would like to do is split out
the text data based on the comma. So let's say that my
cell contains the following: Red, Blue

This is my code:
Text_Array = Split(CurrentCell,Chr(44))
MsgBox Text_Array(0)
MsgBox Text_Array(1)

So I would expect to see two message boxes, the first one

to say Red, the second to say Blue. But when I do this, I
get an error message that says "Subscript out of range".
Is there something that I am doing wrong?

Thanks,
Chris
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Splitting out text in VBA

I don't know what CurrentCell is but this works

Sub a()
Dim Text_Array As Variant
Text_Array = Split(ActiveCell.Value, Chr(44))
MsgBox Text_Array(0)
MsgBox Text_Array(1)
End Sub


--
Jim Rech
Excel MVP


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
Splitting Text jazzzbo Excel Discussion (Misc queries) 2 February 2nd 10 10:09 PM
Splitting Text? Ken Excel Discussion (Misc queries) 4 January 16th 09 05:13 PM
Splitting text LLG-CN Excel Discussion (Misc queries) 11 November 12th 08 06:58 PM
Splitting Text John Calder New Users to Excel 4 July 27th 07 04:00 AM
Splitting text into 2 collumns exceluser2 Excel Discussion (Misc queries) 4 March 26th 06 07:26 PM


All times are GMT +1. The time now is 06:21 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"