Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,045
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.
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
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 04:40 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"