PC Review


Reply
Thread Tools Rate Thread

copy cell until data doesnt exitst anymore

 
 
Daniel M
Guest
Posts: n/a
 
      18th Jan 2008
I have a macro i need to write that does the following. select a cell (A1)
and start scanning in serial number with my barcode scanner.

The data looks like this "02-20025002-00583802-00747102-006914"

I then put this formula into A2. "=MID($A$1,1+(ROW()-2)*9,9)"

This splits the long string into individual serial numbers. I then have to
copy that formula into A3-Ax until the data stops filling in. Then i copy the
data and paste special values to get just the data i want and delete A1.

The questions is can i make this formula paste until it stops putting in
data and then do the rest of the steps without having to manually do it? Or
is there some other way to do it? Thanks.

dm.
 
Reply With Quote
 
 
 
 
dbKemp
Guest
Posts: n/a
 
      18th Jan 2008
On Jan 18, 9:38 am, Daniel M <Dani...@discussions.microsoft.com>
wrote:
> I have a macro i need to write that does the following. select a cell (A1)
> and start scanning in serial number with my barcode scanner.
>
> The data looks like this "02-20025002-00583802-00747102-006914"
>
> I then put this formula into A2. "=MID($A$1,1+(ROW()-2)*9,9)"
>
> This splits the long string into individual serial numbers. I then have to
> copy that formula into A3-Ax until the data stops filling in. Then i copy the
> data and paste special values to get just the data i want and delete A1.
>
> The questions is can i make this formula paste until it stops putting in
> data and then do the rest of the steps without having to manually do it? Or
> is there some other way to do it? Thanks.
>
> dm.


It looks like the serial numbers are separated by '-'. If so, you
could use the split function with '-' as a delimeter and then write
the array to the appropriate Excel range.
 
Reply With Quote
 
Daniel M
Guest
Posts: n/a
 
      18th Jan 2008
No the serial numbers are not split with a -. they are 02-123456 format. so
running all together you see 02-12345602-12345702-123458


"dbKemp" wrote:

> On Jan 18, 9:38 am, Daniel M <Dani...@discussions.microsoft.com>
> wrote:
> > I have a macro i need to write that does the following. select a cell (A1)
> > and start scanning in serial number with my barcode scanner.
> >
> > The data looks like this "02-20025002-00583802-00747102-006914"
> >
> > I then put this formula into A2. "=MID($A$1,1+(ROW()-2)*9,9)"
> >
> > This splits the long string into individual serial numbers. I then have to
> > copy that formula into A3-Ax until the data stops filling in. Then i copy the
> > data and paste special values to get just the data i want and delete A1.
> >
> > The questions is can i make this formula paste until it stops putting in
> > data and then do the rest of the steps without having to manually do it? Or
> > is there some other way to do it? Thanks.
> >
> > dm.

>
> It looks like the serial numbers are separated by '-'. If so, you
> could use the split function with '-' as a delimeter and then write
> the array to the appropriate Excel range.
>

 
Reply With Quote
 
dbKemp
Guest
Posts: n/a
 
      21st Jan 2008
On Jan 18, 5:41 pm, Daniel M <Dani...@discussions.microsoft.com>
wrote:
> No the serial numbers are not split with a -. they are 02-123456 format. so
> running all together you see 02-12345602-12345702-123458
>
> "dbKemp" wrote:
> > On Jan 18, 9:38 am, Daniel M <Dani...@discussions.microsoft.com>
> > wrote:
> > > I have a macro i need to write that does the following. select a cell (A1)
> > > and start scanning in serial number with my barcode scanner.

>
> > > The data looks like this "02-20025002-00583802-00747102-006914"

>
> > > I then put this formula into A2. "=MID($A$1,1+(ROW()-2)*9,9)"

>
> > > This splits the long string into individual serial numbers. I then have to
> > > copy that formula into A3-Ax until the data stops filling in. Then i copy the
> > > data and paste special values to get just the data i want and delete A1.

>
> > > The questions is can i make this formula paste until it stops putting in
> > > data and then do the rest of the steps without having to manually do it? Or
> > > is there some other way to do it? Thanks.

>
> > > dm.

>
> > It looks like the serial numbers are separated by '-'. If so, you
> > could use the split function with '-' as a delimeter and then write
> > the array to the appropriate Excel range.


Try this:
Public Sub Main()
SplitSN Target:=ActiveCell
End Sub

Private Sub SplitSN(ByRef Target As Excel.Range)
Dim sInput As String
Dim sOutput() As String
Dim lUpperBound As Long
Dim lCtr As Long

sInput = Target.Value
lUpperBound = (Len(sInput) / 9) - 1
ReDim sOutput(lUpperBound)
For lCtr = 0 To lUpperBound
sOutput(lCtr) = Mid$(sInput, lCtr * 9 + 1, 9)
Next
Target.Offset(1, 0).Resize(lUpperBound + 1, 1).Value =
Application.WorksheetFunction.Transpose(sOutput)
End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Validation doesnt work with Copy/Paste xmux Microsoft Excel Worksheet Functions 2 18th Mar 2009 03:40 PM
Data Validation doesnt work with Copy/Paste xmux Microsoft Excel Programming 1 18th Mar 2009 01:27 PM
Formula doesnt work when copy in different cell =?Utf-8?B?TWF0?= Microsoft Excel Misc 3 20th Apr 2007 08:34 PM
network doesnt work anymore...HELP! Sammy Smith Windows XP Help 2 27th Jan 2006 08:37 AM
XP doesnt save settings anymore Cameron Windows XP Performance 1 28th Nov 2003 07:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:17 AM.