Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need to divide value across added rows

I have a customer sheet with 2-3 thousand rows, each with 24 columns.
At any time, a row may be split(new row) and the values in A thru D
(names) and from column K (due) copy/pasted to the new row, and a text
value added to column E to note it. I've managed to do that with a
macro, probably with many more lines than necessary.
I now need to split that dollar value in column K into THREE new rows
when I copy it (payments), what code do I add to get three equal
amounts in those three new rows? Is there a quicker way to do this
without the 40 lines of code I have now?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default need to divide value across added rows

I would use the worksheet function floor. Because 3 doesn't evenly divide
two rows will get same value you want two rows to have the same value and one
row to be only offf by .01.

Sub splitdollar()

originaltotal = 15.62
Div3total = WorksheetFunction.Floor(originaltotal / 3, 0.01)
row1total = Div3total
Tworowtotal = originaltotal - Div3total
Div2total = WorksheetFunction. _
Floor((Tworowtotal) / 2, 0.01)
row2total = Div2total
row3total = Tworowtotal - Div2total

End Sub

" wrote:

I have a customer sheet with 2-3 thousand rows, each with 24 columns.
At any time, a row may be split(new row) and the values in A thru D
(names) and from column K (due) copy/pasted to the new row, and a text
value added to column E to note it. I've managed to do that with a
macro, probably with many more lines than necessary.
I now need to split that dollar value in column K into THREE new rows
when I copy it (payments), what code do I add to get three equal
amounts in those three new rows? Is there a quicker way to do this
without the 40 lines of code I have now?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default need to divide value across added rows

since my original total varies by customer, how do I enter something
like active row cell K as the input? This is only needed for aprx 1
of every 100 customers.
I am trying to have a macro that will invoke adding three rows, split
cell K into three and place the partial amounts into the 'new' cell
K's. I can do that now with only one new row - more than that and I
get lost in VBA.


On Mon, 13 Aug 2007 04:22:01 -0700, Joel
wrote:

I would use the worksheet function floor. Because 3 doesn't evenly divide
two rows will get same value you want two rows to have the same value and one
row to be only offf by .01.

Sub splitdollar()

originaltotal = 15.62
Div3total = WorksheetFunction.Floor(originaltotal / 3, 0.01)
row1total = Div3total
Tworowtotal = originaltotal - Div3total
Div2total = WorksheetFunction. _
Floor((Tworowtotal) / 2, 0.01)
row2total = Div2total
row3total = Tworowtotal - Div2total

End Sub

" wrote:

I have a customer sheet with 2-3 thousand rows, each with 24 columns.
At any time, a row may be split(new row) and the values in A thru D
(names) and from column K (due) copy/pasted to the new row, and a text
value added to column E to note it. I've managed to do that with a
macro, probably with many more lines than necessary.
I now need to split that dollar value in column K into THREE new rows
when I copy it (payments), what code do I add to get three equal
amounts in those three new rows? Is there a quicker way to do this
without the 40 lines of code I have now?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default need to divide value across added rows

You may just want to add one row three times. Or

rows($3:$5).insert

or

RowCount = 25
rows(RowCount & ":" & (RowCount + 2)).insert

"OzonedMan" wrote:

since my original total varies by customer, how do I enter something
like active row cell K as the input? This is only needed for aprx 1
of every 100 customers.
I am trying to have a macro that will invoke adding three rows, split
cell K into three and place the partial amounts into the 'new' cell
K's. I can do that now with only one new row - more than that and I
get lost in VBA.


On Mon, 13 Aug 2007 04:22:01 -0700, Joel
wrote:

I would use the worksheet function floor. Because 3 doesn't evenly divide
two rows will get same value you want two rows to have the same value and one
row to be only offf by .01.

Sub splitdollar()

originaltotal = 15.62
Div3total = WorksheetFunction.Floor(originaltotal / 3, 0.01)
row1total = Div3total
Tworowtotal = originaltotal - Div3total
Div2total = WorksheetFunction. _
Floor((Tworowtotal) / 2, 0.01)
row2total = Div2total
row3total = Tworowtotal - Div2total

End Sub

" wrote:

I have a customer sheet with 2-3 thousand rows, each with 24 columns.
At any time, a row may be split(new row) and the values in A thru D
(names) and from column K (due) copy/pasted to the new row, and a text
value added to column E to note it. I've managed to do that with a
macro, probably with many more lines than necessary.
I now need to split that dollar value in column K into THREE new rows
when I copy it (payments), what code do I add to get three equal
amounts in those three new rows? Is there a quicker way to do this
without the 40 lines of code I have now?


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
how can i divide an xl sht into 2 sections with diff placed rows Jenny Excel Discussion (Misc queries) 3 March 22nd 09 07:50 AM
To take the cells in the same row and divide them in rows [email protected] Excel Discussion (Misc queries) 5 August 11th 07 01:42 PM
Divide Cell Across Rows dee Excel Programming 6 September 26th 06 08:35 AM
Looking for a formula that will divide a column & rows by 2 anchar Excel Worksheet Functions 2 August 12th 06 04:46 PM
I Need to divide all cells in rows 2 and 3 by 100 Brent E Excel Discussion (Misc queries) 3 December 23rd 04 11:27 PM


All times are GMT +1. The time now is 11:40 PM.

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

About Us

"It's about Microsoft Excel"