Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating New Lines from original


Have an exisiting line on a worksheet that has a cell that identifie
that it is a combination of lines

Know the logic behind the combine ie if Combine should be individua
line for Dept X, Dept Y and Dept Z

Want to know how I can extract this data onto another worksheet.

Might be best to show an example:-

Example Line on exising worksheet
Date Account Number Combine

Output required

Date Account Number Dept X
Date Account Number Dept Y
Date Account Number Dept Z

Any ideas on the code to do this

--
Balthasar
-----------------------------------------------------------------------
Balthasar G's Profile: http://www.excelforum.com/member.php...fo&userid=3726
View this thread: http://www.excelforum.com/showthread.php?threadid=57212

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Creating New Lines from original

Is it always the same X, Y, and Z? What if the word Combine isn't there?
What do want as the output then? HTH Otto
"Balthasar G"
wrote in message
...

Have an exisiting line on a worksheet that has a cell that identifies
that it is a combination of lines

Know the logic behind the combine ie if Combine should be individual
line for Dept X, Dept Y and Dept Z

Want to know how I can extract this data onto another worksheet.

Might be best to show an example:-

Example Line on exising worksheet
Date Account Number Combine

Output required

Date Account Number Dept X
Date Account Number Dept Y
Date Account Number Dept Z

Any ideas on the code to do this.


--
Balthasar G
------------------------------------------------------------------------
Balthasar G's Profile:
http://www.excelforum.com/member.php...o&userid=37264
View this thread: http://www.excelforum.com/showthread...hreadid=572125



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating New Lines from original


Hi
Its always the same X Y Z
If the word combine is not there it should just output the line as it
stands to the new worksheet.
If the word combine is there it should produce a line for each of the
dept on the new worksheet.

Hope this helps.


--
Balthasar G
------------------------------------------------------------------------
Balthasar G's Profile: http://www.excelforum.com/member.php...o&userid=37264
View this thread: http://www.excelforum.com/showthread...hreadid=572125

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating New Lines from original


Input Worksheet

Date, Account Number, Combine
Date, Account Number,


Output Worksheet

Date Account Number, Dep X
Date Account Number, Dep Y
Date Account Number, Dep Z
Date Account Number,


--
Balthasar G
------------------------------------------------------------------------
Balthasar G's Profile: http://www.excelforum.com/member.php...o&userid=37264
View this thread: http://www.excelforum.com/showthread...hreadid=572125

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Creating New Lines from original

Balthasar
This macro will do what you want. I assumed that the original data is
in Column A starting in row 2 with row 1 being headers. Note that the sheet
with the original data must be the active sheet (the sheet on the screen).
I chose a sheet name of "Two" for the destination sheet. Sheet 2 also has
headers in row 1. This sheet name ("Two") is written in the macro so you
must change that name in the macro to your actual sheet name. HTH Otto
Sub DoData()
Dim RngColA As Range
Dim i As Range
Dim Dest As Range
With Sheets("Two")
Set Dest = .Range("A2", .Range("A" &
Rows.Count).End(xlUp).Offset(1))
End With
Set RngColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For Each i In RngColA
If i.Offset(, 2).Value = "Combine" Then
i.Resize(, 2).Copy Dest.Resize(3)
Dest.Offset(, 2).Value = "Dep X"
Dest.Offset(1, 2).Value = "Dep Y"
Dest.Offset(2, 2).Value = "Dep Z"
Set Dest = Dest.Offset(3)
Else
i.Resize(, 2).Copy Dest
Set Dest = Dest.Offset(1)
End If
Next i
End Sub
"Balthasar G"
wrote in message
...

Input Worksheet

Date, Account Number, Combine
Date, Account Number,


Output Worksheet

Date Account Number, Dep X
Date Account Number, Dep Y
Date Account Number, Dep Z
Date Account Number,


--
Balthasar G
------------------------------------------------------------------------
Balthasar G's Profile:
http://www.excelforum.com/member.php...o&userid=37264
View this thread: http://www.excelforum.com/showthread...hreadid=572125





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Creating New Lines from original

I don't see my reply so I'll send it again. Otto
Sub DoData()
Dim RngColA As Range
Dim i As Range
Dim Dest As Range
With Sheets("Two")
Set Dest = .Range("A2", .Range("A" &
Rows.Count).End(xlUp).Offset(1))
End With
Set RngColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For Each i In RngColA
If i.Offset(, 2).Value = "Combine" Then
i.Resize(, 2).Copy Dest.Resize(3)
Dest.Offset(, 2).Value = "Dep X"
Dest.Offset(1, 2).Value = "Dep Y"
Dest.Offset(2, 2).Value = "Dep Z"
Set Dest = Dest.Offset(3)
Else
i.Resize(, 2).Copy Dest
Set Dest = Dest.Offset(1)
End If
Next i
End Sub
"Balthasar G"
wrote in message
...

Input Worksheet

Date, Account Number, Combine
Date, Account Number,


Output Worksheet

Date Account Number, Dep X
Date Account Number, Dep Y
Date Account Number, Dep Z
Date Account Number,


--
Balthasar G
------------------------------------------------------------------------
Balthasar G's Profile:
http://www.excelforum.com/member.php...o&userid=37264
View this thread: http://www.excelforum.com/showthread...hreadid=572125



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating New Lines from original


Got one more issue.
Having now looked at the spreadsheet I need to perfom this on it has 42
columns with the "Combine" field in column 10.

Having real difficulty changing the code to cope with this.

Wonder if you could assist.

Thanks


--
Balthasar G
------------------------------------------------------------------------
Balthasar G's Profile: http://www.excelforum.com/member.php...o&userid=37264
View this thread: http://www.excelforum.com/showthread...hreadid=572125

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Creating New Lines from original

Balthasar
I just don't know what you want to do. What do you want done with the
42 columns? I take it that you still have the situation where some of the
rows have "Combine" and some don't. Give me some examples like you did
before. HTH Otto
"Balthasar G"
wrote in message
...

Got one more issue.
Having now looked at the spreadsheet I need to perfom this on it has 42
columns with the "Combine" field in column 10.

Having real difficulty changing the code to cope with this.

Wonder if you could assist.

Thanks


--
Balthasar G
------------------------------------------------------------------------
Balthasar G's Profile:
http://www.excelforum.com/member.php...o&userid=37264
View this thread: http://www.excelforum.com/showthread...hreadid=572125



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating New Lines from original


Otto
Have spent most of today working on this and have managed to get it t
work.
Thanks again for your assistance and most of all for your patience.
Cheers
Bal

--
Balthasar
-----------------------------------------------------------------------
Balthasar G's Profile: http://www.excelforum.com/member.php...fo&userid=3726
View this thread: http://www.excelforum.com/showthread.php?threadid=57212

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
Creating a bar chart that also contains two lines Frustratedfemale26 Excel Discussion (Misc queries) 4 August 25th 09 03:22 PM
Can you make a cell = 0 if original function is creating a"#ref!"? DaveinNeedofHelp Excel Worksheet Functions 5 April 7th 09 09:42 PM
hide original cells after creating chart tcurrier Charts and Charting in Excel 2 March 15th 06 01:42 PM
Auto save replaced my original file and now I need the original? Hols Excel Discussion (Misc queries) 1 August 15th 05 10:34 PM
creating 2 lines within one cell Karen Hanson Excel Discussion (Misc queries) 1 December 1st 04 10:47 PM


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