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 for splitting lines

YES!

That did the trick! I deeply appreciate your help:-)

BR
André

"Per Jessen" skrev i melding
...
Hi André

Try this:

Sub bbb()
Dim TargetSh As Worksheet
Dim Off As Long

Set TargetSh = Worksheets("Sheet2")
FirstRow = 2
LastRow = Range("A1").End(xlDown).Row

For r = FirstRow To LastRow
ItemNo = Cells(r, 1).Value
For ItemCount = 1 To Cells(r, 2).Value
TargetSh.Range("A2").Offset(Off, 0) = ItemNo & "-" & ItemCount
Off = Off + 1
Next
Next
End Sub

Regards,
Per

On 4 Apr., 13:17, "André" wrote:
Hi,

I'm close to finally being able to automate a huge and boring job, but I
have a problem which hopefully some of you experts can help me solve.

I have a large excel-sheet with two columns, ItemNo and number (number of
items).

ItemNo. Number
10000 1
10001 2
10002 1
10007 9
etc.

I need a macro that transaltes the above columns to a new sheet within the
same excel-file. The new sheet need to have only one column, which
consists
of the two columns joined together. That's easy, but my challange is to
give
me 9 lines if the number is 9, AND with the same itemno, but with
ascending
numbers from 1 to x. The new file should look like this:

New number
10000-1
10001-1 (number = 2)
10001-2 "
10002-1
10007-1 (number = 9)
10007-2 "
10007-3 "
10007-4 "
10007-5 "
10007-6 "
10007-7 "
10007-8 "
10007-9 "
etc.

Probably an easy task for a programmer, but not for me:-(

Do you have any suggestion on how to solve this?

Best regards,
André



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
Splitting data from cells into multiple lines Igneshwara reddy[_2_] Excel Worksheet Functions 6 May 6th 09 08:15 PM
Splitting comma separated lines of an address for mail merge. Chuda Excel Discussion (Misc queries) 1 September 12th 06 01:04 PM
Carriage Return and Splitting Lines to Lotus Notes Msg through VBA skiloa Excel Programming 3 June 8th 05 01:28 PM
splitting my header into two lines Bryan N Excel Worksheet Functions 1 May 26th 05 08:54 PM
splitting text in two lines Tim Williams Excel Programming 0 August 19th 03 06:48 AM


All times are GMT +1. The time now is 06:58 AM.

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"