Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default split cell in number-cell and letter-cell

Hi Expert,

I would like a loop-routine to split out (letter and number) cells in
a letter and a number cell, like:
(It has to be implemented by a vba routine, no worksheet formula)
The first part are always letters, the last part numbers.

input: output after routine:
cellColumnA: cellColumnB: cellColumnC:
peterpan 89772 peterpan 89772

Please, could someone help me out?

best regards,
Peter

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default split cell in number-cell and letter-cell

select yr range of cells to split and use this

Sub cus()
Dim cell As Range

For Each cell In Selection
On Error Resume Next
For i = 1 To Len(ActiveCell.Value)
If Not IsNumeric(Mid(ActiveCell.Value, i, 1) * 1) Then
GoTo follow
Else
Exit For
End If
follow:
Next i

ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 1)
ActiveCell.Offset(0, 2) = Mid(ActiveCell.Value, i, Len
(ActiveCell.Value) - i + 1)

Next cell

End Sub

HIH


On 3 Lis, 10:57, ppeer wrote:
Hi Expert,

I would like a loop-routine to split out (letter and number) cells in
a letter and a number cell, like:
(It has to be implemented by a vba routine, no worksheet formula)
The first part are always letters, the last part numbers.

input: * * * * * * * * * * * * * * output after routine:
cellColumnA: * * * * * * * * cellColumnB: * * * * * * * *cellColumnC:
peterpan 89772 * * * * * * peterpan * * * * * * * * * * * *89772

Please, could someone help me out?

best regards,
Peter


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default split cell in number-cell and letter-cell

On 3 nov, 11:45, Jarek Kujawa wrote:
select yr range of cells to split and use this

Sub cus()
Dim cell As Range

For Each cell In Selection
On Error Resume Next
For i = 1 To Len(ActiveCell.Value)
If Not IsNumeric(Mid(ActiveCell.Value, i, 1) * 1) Then
GoTo follow
Else
Exit For
End If
follow:
Next i

ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 1)
ActiveCell.Offset(0, 2) = Mid(ActiveCell.Value, i, Len
(ActiveCell.Value) - i + 1)

Next cell

End Sub

HIH

On 3 Lis, 10:57, ppeer wrote:



Hi Expert,


I would like a loop-routine to split out (letter and number) cells in
a letter and a number cell, like:
(It has to be implemented by a vba routine, no worksheet formula)
The first part are always letters, the last part numbers.


input: * * * * * * * * * * * * * * output after routine:
cellColumnA: * * * * * * * * cellColumnB: * * * * * * * *cellColumnC:
peterpan 89772 * * * * * * peterpan * * * * * * * * * * * *89772


Please, could someone help me out?


best regards,
Peter- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven


Works Perfectly!!! Thanks a lot...
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 896
Default split cell in number-cell and letter-cell

in yr example you'll be left with "peterpan "
if you prefer to have no trailing spaces change

ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 1)

to

ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 2)

or use Edit-Replace to get rid of them

pls click YES if it helped


On 3 Lis, 11:53, ppeer wrote:
On 3 nov, 11:45, Jarek Kujawa wrote:





select yr range of cells to split and use this


Sub cus()
Dim cell As Range


For Each cell In Selection
On Error Resume Next
For i = 1 To Len(ActiveCell.Value)
If Not IsNumeric(Mid(ActiveCell.Value, i, 1) * 1) Then
GoTo follow
Else
Exit For
End If
follow:
Next i


ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 1)
ActiveCell.Offset(0, 2) = Mid(ActiveCell.Value, i, Len
(ActiveCell.Value) - i + 1)


Next cell


End Sub


HIH


On 3 Lis, 10:57, ppeer wrote:


Hi Expert,


I would like a loop-routine to split out (letter and number) cells in
a letter and a number cell, like:
(It has to be implemented by a vba routine, no worksheet formula)
The first part are always letters, the last part numbers.


input: * * * * * * * * * * * * * * output after routine:
cellColumnA: * * * * * * * * cellColumnB: * * * * * * * *cellColumnC:
peterpan 89772 * * * * * * peterpan * * * * * * * * * * * *89772


Please, could someone help me out?


best regards,
Peter- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven


Works Perfectly!!! Thanks a lot...- Ukryj cytowany tekst -

- Pokaż cytowany tekst -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Yes

Thanks again, I am now using your suggestion (-2)

Jarek Kujawa schreef:
in yr example you'll be left with "peterpan "
if you prefer to have no trailing spaces change

ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 1)

to

ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 2)

or use Edit-Replace to get rid of them

pls click YES if it helped


On 3 Lis, 11:53, ppeer wrote:
On 3 nov, 11:45, Jarek Kujawa wrote:





select yr range of cells to split and use this


Sub cus()
Dim cell As Range


For Each cell In Selection
On Error Resume Next
For i = 1 To Len(ActiveCell.Value)
If Not IsNumeric(Mid(ActiveCell.Value, i, 1) * 1) Then
GoTo follow
Else
Exit For
End If
follow:
Next i


ActiveCell.Offset(0, 1) = Mid(ActiveCell.Value, 1, i - 1)
ActiveCell.Offset(0, 2) = Mid(ActiveCell.Value, i, Len
(ActiveCell.Value) - i + 1)


Next cell


End Sub


HIH


On 3 Lis, 10:57, ppeer wrote:


Hi Expert,


I would like a loop-routine to split out (letter and number) cells in
a letter and a number cell, like:
(It has to be implemented by a vba routine, no worksheet formula)
The first part are always letters, the last part numbers.


input: * * * * * * * * * * * * * * output after routine:
cellColumnA: * * * * * * * * cellColumnB: * * * * * * * *cellColumnC:
peterpan 89772 * * * * * * peterpan * * * * * * * * * * * *89772


Please, could someone help me out?


best regards,
Peter- Tekst uit oorspronkelijk bericht niet weergeven -


- Tekst uit oorspronkelijk bericht weergeven


Works Perfectly!!! Thanks a lot...- Ukryj cytowany tekst -

- Pokaż cytowany tekst -

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
Split a number in a cell into parts okanem Excel Discussion (Misc queries) 4 August 21st 06 03:59 PM
HOW DO I ADD A LETTER BEFORE AN EXISTING NUMBER IN A CELL? PAULP Excel Worksheet Functions 8 January 27th 06 07:16 PM
how to add a letter in front of each number in a cell nmodafferi Excel Discussion (Misc queries) 15 June 16th 05 08:58 PM
How do I add row total when cell contains both number and letter . cbarcroft Excel Discussion (Misc queries) 4 April 18th 05 11:52 PM
How do I get a letter in one cell ito equal a number in anotherl.. Dave Cadey Excel Discussion (Misc queries) 4 February 25th 05 02:37 PM


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