A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macro Creating Auto Separation of Numbers thru Defining Delimiter



 
 
Thread Tools Display Modes
  #1  
Old August 11th 12, 02:05 AM posted to microsoft.public.excel.programming
GammaRuit
external usenet poster
 
Posts: 8
Default Macro Creating Auto Separation of Numbers thru Defining Delimiter

Im trying to write a program where a alphanumeric is typed into a cell A1

(ex. 2345n2375n2938n6475n2938)

Once the macro reads this i need the macro to break this down using "n" as a delimiter and out put into B1-5
then automatically return to a1 clear the data in the cell and wait for another number to be inputed

the output needs to look like this like this

b1 contains 2345
b2 contains 2375
b3 contains 2938
b4 contains 6475
b5 contains 2938
Ads
  #2  
Old August 11th 12, 03:59 AM posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_]
external usenet poster
 
Posts: 894
Default Macro Creating Auto Separation of Numbers thru Defining Delimiter

On Fri, 10 Aug 2012 18:05:17 -0700 (PDT), GammaRuit > wrote:

>Im trying to write a program where a alphanumeric is typed into a cell A1
>
>(ex. 2345n2375n2938n6475n2938)
>
>Once the macro reads this i need the macro to break this down using "n" as a delimiter and out put into B1-5
>then automatically return to a1 clear the data in the cell and wait for another number to be inputed
>
>the output needs to look like this like this
>
>b1 contains 2345
>b2 contains 2375
>b3 contains 2938
>b4 contains 6475
>b5 contains 2938


Here's one way with an event-triggered macro

To enter this event-triggered Macro, right click on the sheet tab.
Select "View Code" from the right-click drop-down menu.
Then paste the code below into the window that opens.

====================================
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, r1 As Range
Dim v As Variant
Set r1 = Range("a1")
Application.EnableEvents = False
If Not Intersect(r1, Target) Is Nothing Then
If Len(r1.Text) > 0 Then
v = Split(r1.Text, "n")
Set r = r1.Offset(columnoffset:=1).Resize(rowsize:=UBound( v) - LBound(v) + 1)
r.EntireColumn.ClearContents
r = WorksheetFunction.Transpose(v)
r1.ClearContents
End If
End If
Application.EnableEvents = True
End Sub
========================

As written, the routine is case sensitive. For a case insensitive version, add the line:

Option Compare Text

at the very beginning, above the Private Sub .... line.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse delimiter is change from text to numbers ORLANDO V[_2_] Excel Discussion (Misc queries) 11 January 2nd 09 06:56 PM
separation of text and numbers in an unmerged cell Tazeem Excel Discussion (Misc queries) 9 September 16th 08 10:01 AM
defining names in a macro guidop12 Excel Discussion (Misc queries) 6 August 28th 08 11:56 PM
Need importing macro to recognize #*# as delimiter Eric Bragas[_2_] Excel Programming 3 December 4th 06 07:29 PM
Defining an auto-open macro that prints specific worksheets sam[_3_] Excel Programming 1 November 21st 03 08:52 PM


All times are GMT +1. The time now is 08:56 AM.


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