Technology Get the latest on technology, electronics and software…

Need Excel help

Thread Tools
 
Old Aug 7, 2009 | 05:37 PM
  #1  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
Need Excel help

Could one of the excel gurus on the site give me a hand with a formula?

the sheet looks like this:

Title 1 12.0%
Title 2 31.0%
Title 3 24.0%
Title 4 5.0%
Title 5 6.0%
Title 6 7.0%
Title 7 7.0%
Title 8 8.0%
100.0%

What I need is all the % values to be able to be changed by the user, and have the others adjust to equal 100%.So if I changed say title 2 to 5%, the other values will auto adjust to distribute the difference and equal 100%. A few of us have been stumped by this, I'm hoping someone can solve it, if it's possible.
Reply
Old Aug 7, 2009 | 05:53 PM
  #2  
jupitersolo's Avatar
nnInn
 
Joined: Mar 2006
Posts: 37,670
Likes: 1,084
Man, I know my wife would loved to do this, but she's not here tonight.
Reply
Old Aug 7, 2009 | 08:01 PM
  #3  
Anachostic's Avatar
Safety Car
 
Joined: Jul 2007
Posts: 4,845
Likes: 145
Here's a typical-for-me overdone VBA solution. I'm not sure you can do what you want with an Excel function, because you would need to track both a value and a have a function in a cell, which a cell can only have one or the other.

So, open up the VBA editor (Alt-F11), open up Sheet1 or whatever your sheet is called, and paste this in.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim i As Integer
    Dim oldValue As Double
    Dim newValue As Double
    Dim oldSum As Double
    Dim delta As Double
    Dim maxRows As Integer
    
    ' Set this to the number of rows you are summing to 100%
    maxRows = 8

    If Not IsNumeric(Target.Value) Then Exit Sub
    If Target.Count > 1 Then Exit Sub
        
    Application.EnableEvents = False
    
    ' get old Value
    newValue = Target.Value
    Application.Undo
    oldValue = Target.Value
    Target.Value = newValue
    
    ' Get the sum before the change
    For i = 1 To maxRows
        If i <> Target.Row Then
            oldSum = oldSum + Me.Cells(i, Target.Column)
        End If
        
    Next
    
    ' Don't start recalulating until we hit 100%
    If oldSum + oldValue < 1 Then
          Application.EnableEvents = True
        Exit Sub
    End If
    
    ' Figure out how much the other cells need to change by
    If oldSum <> 0 Then
        delta = (1 - Target.Value) / (1 - (1 - oldSum))
    Else
        delta = 0
    End If
    
    ' update all the other cells
    For i = 1 To maxRows
        If i <> Target.Row Then
            Me.Cells(i, Target.Column) = Me.Cells(i, Target.Column) * delta
        End If
        
    Next

    Application.EnableEvents = True
    
End Sub
You will need to update the number or rows you are summing to be 100% (1) in the code. Once you have reached 100, every cell you change will affect all the others. There may be times when you want to start over with new starting values. In that case, set every cell to zero and start over. The rebalancing won't happen until you hit 100%.

One annoyance is that you will have to arrow out of your cells twice. It's a side effect of the Undo command I use to get the old value of the cell. Hopefully you can live with it.

Hope this helps.

Last edited by Anachostic; Aug 7, 2009 at 08:01 PM. Reason: clarification
Reply
Old Aug 8, 2009 | 03:13 AM
  #4  
stogie1020's Avatar
Needs more Lemon Pledge
 
Joined: Mar 2005
Posts: 52,768
Likes: 2,000
From: Phoenix, AZ
Wow! Hows THAT for a solution!!


Someone owes someone else a case of beer!
Reply
Old Aug 8, 2009 | 09:16 AM
  #5  
KaMLuNg's Avatar
Senior Moderator
20 Year Member
Liked
Loved
Community Favorite
iTrader: (5)
 
Joined: Feb 2002
Posts: 15,518
Likes: 1,096
holy fcuk... my excel skills really suck after seeing that... i thought i was he sh!t...
Reply
Old Aug 8, 2009 | 09:24 AM
  #6  
paz840's Avatar
Suzuka Master
iTrader: (2)
 
Joined: Sep 2006
Posts: 6,083
Likes: 42
From: St. Louis
Reply
Old Aug 8, 2009 | 12:51 PM
  #7  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
WOW, that is awesome, I'm kind of excited to try it out when I get home. This website is the tits.
Reply
Old Oct 21, 2009 | 09:26 AM
  #8  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
Ok, with the success of my last request, maybe someone can help me again.

I have a massive excel file, and need to automate a proccess because doing it manual could kill me. There's a Master sheet about 100 rows by 160 columns. Each row is a product and each column are product specs. From this master sheet, I need to create a seperate sheet for each of the rows (products). The new sheet is a template and certain cells need to be populated with the info from the Master sheet. I have done a few of these and I just have those cells linked to the respective cell on the master. Is there a way I can create a copy of this template, but have the formula basically go from referencing cell C3 to C4 and so on up to 100. I need a way to make this fast and easy.
Reply
Old Oct 21, 2009 | 10:04 AM
  #9  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
is it possible for this to work:

My forumla is =MASTER!H5

instead of having the 5 in H5, could I make that a link to a cell in my sheet where I can change the number. I.E =MASTER!H(B6) and whatever that value is will make it look up that row in my master sheet?
Reply
Old Oct 21, 2009 | 10:43 AM
  #10  
rza49311's Avatar
Drifting
iTrader: (1)
 
Joined: Feb 2006
Posts: 3,072
Likes: 8
From: Southern VA
quick question, have you tried to copy > paste special > formula?
Reply
Old Oct 21, 2009 | 12:42 PM
  #11  
moeronn's Avatar
is learning to moonwalk i
 
Joined: Feb 2004
Posts: 15,520
Likes: 3
From: SoCal
I'm no help, but am interested in what the answer is.
Reply
Old Oct 21, 2009 | 01:06 PM
  #12  
svtmike's Avatar
Team Owner
20 Year Member
Liked
Loved
Community Favorite
 
Joined: Oct 2003
Posts: 37,701
Likes: 3,897
From: Chicago
Two ways to approach:

1) Pull the table into Access and make a report.

2) Excel -- write a VBA function to traverse the table and make the detail sheets you want.

I'm not going to do them for you though.
Reply
Old Oct 21, 2009 | 01:45 PM
  #13  
imj0257's Avatar
Q('.')=O
15 Year Member
Liked
Loved
Community Favorite
iTrader: (1)
 
Joined: Feb 2008
Posts: 23,567
Likes: 730
From: DFW, TX
Anachostic...
Reply
Old Oct 21, 2009 | 09:31 PM
  #14  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
Originally Posted by svtmike
Two ways to approach:

1) Pull the table into Access and make a report.

2) Excel -- write a VBA function to traverse the table and make the detail sheets you want.

I'm not going to do them for you though.
Thanks for the tips mike, I'll look into that for the future. I'm a pretty quick learner with this stuff, but sometimes knowing what to search google for is the hardest part.

I came up with an interim solution, which was to re-write the formulas in the template to use indirect references, and use a random cell on the template to point those forumlas to the correct row. Basically I took it from having to manually change the formulas in like 3000 cells, to changing a reference point in 100.
Reply
Old Oct 21, 2009 | 09:46 PM
  #15  
EuRTSX's Avatar
Team Owner
 
Joined: Feb 2006
Posts: 23,588
Likes: 106
From: District of Corruption
Man, I realized that there was NO point in taking that MCAS Excel certification
Reply
Old Oct 21, 2009 | 09:50 PM
  #16  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
Originally Posted by EuRTSX
Man, I realized that there was NO point in taking that MCAS Excel certification
I learned more in my first week on the job then I did with a semester of MIS. I'm starting to get to a point where the person that receives most of my sheets asks WTF is that function.
Reply
Old Oct 21, 2009 | 09:52 PM
  #17  
EuRTSX's Avatar
Team Owner
 
Joined: Feb 2006
Posts: 23,588
Likes: 106
From: District of Corruption
Originally Posted by The Dougler
I learned more in my first week on the job then I did with a semester of MIS. I'm starting to get to a point where the person that receives most of my sheets asks WTF is that function.
I feel retarded looking at what everyone's saying even though I passed the certification test.

Oh well.
Reply
Old Oct 22, 2009 | 11:17 AM
  #18  
Anachostic's Avatar
Safety Car
 
Joined: Jul 2007
Posts: 4,845
Likes: 145
Originally Posted by The Dougler
is it possible for this to work:

My forumla is =MASTER!H5

instead of having the 5 in H5, could I make that a link to a cell in my sheet where I can change the number. I.E =MASTER!H(B6) and whatever that value is will make it look up that row in my master sheet?
The INDIRECT function might work. it takes a string value and evaluates it to a cell reference.

=INDIRECT(CONCATENATE("MASTER!H",B6))
Reply
Old Oct 22, 2009 | 04:14 PM
  #19  
moeronn's Avatar
is learning to moonwalk i
 
Joined: Feb 2004
Posts: 15,520
Likes: 3
From: SoCal
Hmmm... Isn't this where a lookup table might work?
Reply
Old Oct 22, 2009 | 05:41 PM
  #20  
svtmike's Avatar
Team Owner
20 Year Member
Liked
Loved
Community Favorite
 
Joined: Oct 2003
Posts: 37,701
Likes: 3,897
From: Chicago
Originally Posted by moeronn
Hmmm... Isn't this where a lookup table might work?
I was just thinking that this almost seems like a mailmerge process -- except instead of pulling in address info to a template, you're pulling in the product info.

May want to see if maybe the fastest way is to make the template in Word and use MailMerge to pull in the relevant fields from each row in the spreadsheet.
Reply
Old Oct 22, 2009 | 08:10 PM
  #21  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
Originally Posted by svtmike
I was just thinking that this almost seems like a mailmerge process -- except instead of pulling in address info to a template, you're pulling in the product info.

May want to see if maybe the fastest way is to make the template in Word and use MailMerge to pull in the relevant fields from each row in the spreadsheet.
If I got to make the template I'd do that, but it's provided by one of our customers and we can't change it. Im going to investigate lookup tables as well I've never used one.
Reply
Old Oct 28, 2009 | 09:13 AM
  #22  
The Dougler's Avatar
Thread Starter
Unofficial Goat
iTrader: (1)
 
Joined: Jul 2006
Posts: 15,744
Likes: 112
From: Toronto
new question. If I embed an image on 1 sheet, can I use a link to re-display the image on a subsequent sheet? This is in the interest of keeping the file less than 30mb.
Reply
Old Oct 28, 2009 | 09:40 AM
  #23  
Anachostic's Avatar
Safety Car
 
Joined: Jul 2007
Posts: 4,845
Likes: 145
Originally Posted by The Dougler
new question. If I embed an image on 1 sheet, can I use a link to re-display the image on a subsequent sheet? This is in the interest of keeping the file less than 30mb.
Starting with an empty workbook at 16k, I inserted and image and saved. The file size went to 80k. I copied the image to sheet 2 and saved. The file size went to 80.5k. I inserted the same image file into sheet 3 and saved. The file size went to 81k.

It seems Excel is smart enough to only maintain a single reference to an image within itself and whether you reload the image from disk or copy it internally, it reuses that reference.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Yumcha
Automotive News
70
Dec 7, 2020 05:39 PM
Yumcha
Automotive News
4
Aug 15, 2019 12:58 PM
08_UA7_Gr33k
Member Cars for Sale
13
Feb 11, 2016 02:17 PM
InFaMouSLink
Car Parts for Sale
6
Oct 27, 2015 06:52 PM
08_UA7_Gr33k
Member Cars for Sale
1
Sep 27, 2015 01:56 PM




All times are GMT -5. The time now is 03:01 AM.