Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default using LEN / LEFT / MID / FIND functions to create a list


[Excel 2003]

I have a vlookup which populates cell $A$1 with codes separated by "-". For
example:

"A3-C-D4-F5"

or

"A-C-D5"

or even

"C"

I would like these to be processed so that
on the rows below $A$1, the idividual items are separated out line by line,
such that

A3-C-D4-F5 would be listed as

A3
C
D4
F5

in the cells below. The codes have "-" in various positions (or none at all
in the case of a single item) and can have up to 7 codes in a string.

Sounds complicated..

Can anyone help me separate the individual items from a hyphenized list of
codes as described above?

Thanks, Roger

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default using LEN / LEFT / MID / FIND functions to create a list

This macro will do what you asked for...

Sub SplitText()
Dim X As Long, S() As String
With Range("A1")
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
End Sub

--
Rick (MVP - Excel)


"Roger on Excel" wrote in message
...
[Excel 2003]

I have a vlookup which populates cell $A$1 with codes separated by "-".
For
example:

"A3-C-D4-F5"

or

"A-C-D5"

or even

"C"

I would like these to be processed so that
on the rows below $A$1, the idividual items are separated out line by
line,
such that

A3-C-D4-F5 would be listed as

A3
C
D4
F5

in the cells below. The codes have "-" in various positions (or none at
all
in the case of a single item) and can have up to 7 codes in a string.

Sounds complicated..

Can anyone help me separate the individual items from a hyphenized list of
codes as described above?

Thanks, Roger


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default using LEN / LEFT / MID / FIND functions to create a list


Thanks Rick - this works nicely - is there a way for it to do it
automatically?

Regards,

Roger

"Rick Rothstein" wrote:

This macro will do what you asked for...

Sub SplitText()
Dim X As Long, S() As String
With Range("A1")
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
End Sub

--
Rick (MVP - Excel)


"Roger on Excel" wrote in message
...
[Excel 2003]

I have a vlookup which populates cell $A$1 with codes separated by "-".
For
example:

"A3-C-D4-F5"

or

"A-C-D5"

or even

"C"

I would like these to be processed so that
on the rows below $A$1, the idividual items are separated out line by
line,
such that

A3-C-D4-F5 would be listed as

A3
C
D4
F5

in the cells below. The codes have "-" in various positions (or none at
all
in the case of a single item) and can have up to 7 codes in a string.

Sounds complicated..

Can anyone help me separate the individual items from a hyphenized list of
codes as described above?

Thanks, Roger



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default using LEN / LEFT / MID / FIND functions to create a list

Try this... right click the tab at the bottom of the worksheet where you
want this functionality, select View Code from the popup menu that appears
and Copy/Paste the following into the code window that appeared...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, R As Range, S() As String
For Each R In Target.Dependents
If R.Address = "$A$1" Then
Application.EnableEvents = False
With Range("A1")
.Offset(1).Resize(7).Clear
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
Application.EnableEvents = True
Exit Sub
End If
Next
End Sub

Now, when you make a change to any cell referenced in the VLOOKUP formula in
A1, the value A1 evaluates to should be processed as you wanted.

--
Rick (MVP - Excel)


"Roger on Excel" wrote in message
...

Thanks Rick - this works nicely - is there a way for it to do it
automatically?

Regards,

Roger

"Rick Rothstein" wrote:

This macro will do what you asked for...

Sub SplitText()
Dim X As Long, S() As String
With Range("A1")
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
End Sub

--
Rick (MVP - Excel)


"Roger on Excel" wrote in
message
...
[Excel 2003]

I have a vlookup which populates cell $A$1 with codes separated by "-".
For
example:

"A3-C-D4-F5"

or

"A-C-D5"

or even

"C"

I would like these to be processed so that
on the rows below $A$1, the idividual items are separated out line by
line,
such that

A3-C-D4-F5 would be listed as

A3
C
D4
F5

in the cells below. The codes have "-" in various positions (or none
at
all
in the case of a single item) and can have up to 7 codes in a string.

Sounds complicated..

Can anyone help me separate the individual items from a hyphenized list
of
codes as described above?

Thanks, Roger




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default using LEN / LEFT / MID / FIND functions to create a list

There is a problem with the code I posted earlier; the following should work
correctly (install it the same way)...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, R As Range, TD As Range, S() As String
On Error GoTo NoDependentCells
If Not Target.Dependents Is Nothing Then
For Each R In Target.Dependents
If R.Address = "$A$1" Then
Application.EnableEvents = False
With Range("A1")
.Offset(1).Resize(7).Clear
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
Application.EnableEvents = True
Exit Sub
End If
Next
End If
NoDependentCells:
Application.EnableEvents = True
End Sub

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Try this... right click the tab at the bottom of the worksheet where you
want this functionality, select View Code from the popup menu that appears
and Copy/Paste the following into the code window that appeared...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, R As Range, S() As String
For Each R In Target.Dependents
If R.Address = "$A$1" Then
Application.EnableEvents = False
With Range("A1")
.Offset(1).Resize(7).Clear
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
Application.EnableEvents = True
Exit Sub
End If
Next
End Sub

Now, when you make a change to any cell referenced in the VLOOKUP formula
in A1, the value A1 evaluates to should be processed as you wanted.

--
Rick (MVP - Excel)


"Roger on Excel" wrote in message
...

Thanks Rick - this works nicely - is there a way for it to do it
automatically?

Regards,

Roger

"Rick Rothstein" wrote:

This macro will do what you asked for...

Sub SplitText()
Dim X As Long, S() As String
With Range("A1")
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
End Sub

--
Rick (MVP - Excel)


"Roger on Excel" wrote in
message
...
[Excel 2003]

I have a vlookup which populates cell $A$1 with codes separated by
"-".
For
example:

"A3-C-D4-F5"

or

"A-C-D5"

or even

"C"

I would like these to be processed so that
on the rows below $A$1, the idividual items are separated out line by
line,
such that

A3-C-D4-F5 would be listed as

A3
C
D4
F5

in the cells below. The codes have "-" in various positions (or none
at
all
in the case of a single item) and can have up to 7 codes in a string.

Sounds complicated..

Can anyone help me separate the individual items from a hyphenized
list of
codes as described above?

Thanks, Roger







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default using LEN / LEFT / MID / FIND functions to create a list

Many Thanks Rick,

Works great !

Best regards,

Roger



"Rick Rothstein" wrote:

There is a problem with the code I posted earlier; the following should work
correctly (install it the same way)...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, R As Range, TD As Range, S() As String
On Error GoTo NoDependentCells
If Not Target.Dependents Is Nothing Then
For Each R In Target.Dependents
If R.Address = "$A$1" Then
Application.EnableEvents = False
With Range("A1")
.Offset(1).Resize(7).Clear
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
Application.EnableEvents = True
Exit Sub
End If
Next
End If
NoDependentCells:
Application.EnableEvents = True
End Sub

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Try this... right click the tab at the bottom of the worksheet where you
want this functionality, select View Code from the popup menu that appears
and Copy/Paste the following into the code window that appeared...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, R As Range, S() As String
For Each R In Target.Dependents
If R.Address = "$A$1" Then
Application.EnableEvents = False
With Range("A1")
.Offset(1).Resize(7).Clear
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
Application.EnableEvents = True
Exit Sub
End If
Next
End Sub

Now, when you make a change to any cell referenced in the VLOOKUP formula
in A1, the value A1 evaluates to should be processed as you wanted.

--
Rick (MVP - Excel)


"Roger on Excel" wrote in message
...

Thanks Rick - this works nicely - is there a way for it to do it
automatically?

Regards,

Roger

"Rick Rothstein" wrote:

This macro will do what you asked for...

Sub SplitText()
Dim X As Long, S() As String
With Range("A1")
S = Split(.Value, "-")
For X = 0 To UBound(S)
.Offset(X + 1).Value = S(X)
Next
End With
End Sub

--
Rick (MVP - Excel)


"Roger on Excel" wrote in
message
...
[Excel 2003]

I have a vlookup which populates cell $A$1 with codes separated by
"-".
For
example:

"A3-C-D4-F5"

or

"A-C-D5"

or even

"C"

I would like these to be processed so that
on the rows below $A$1, the idividual items are separated out line by
line,
such that

A3-C-D4-F5 would be listed as

A3
C
D4
F5

in the cells below. The codes have "-" in various positions (or none
at
all
in the case of a single item) and can have up to 7 codes in a string.

Sounds complicated..

Can anyone help me separate the individual items from a hyphenized
list of
codes as described above?

Thanks, Roger






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
using LEN / LEFT / MID / FIND functions to create a list Roger on Excel Excel Discussion (Misc queries) 2 September 14th 09 05:02 AM
Use of Find with Left, Mid, Right functions in nested IF(and('s MJW[_2_] Excel Discussion (Misc queries) 8 September 20th 07 09:22 PM
Where can I find list/table of functions/formulas Rich D Excel Discussion (Misc queries) 8 December 10th 06 11:10 PM
where do i find create list in Excel Steph Excel Worksheet Functions 3 November 13th 06 10:06 PM
Create ListBox (?) same as Find all Result List Soniya Excel Programming 1 October 2nd 03 01:22 PM


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