Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13-02-2009
Member
 
Join Date: Feb 2008
Posts: 767
How to change a percentage in a single cell ?

I want to just assign a percentage reduction on numbers placed in cells. The list box with the % (5, 10 ...) is well established and I have my number in F9. I would now like to change, I choose in my list the percentage that I would grant that the same number in F9 is adapted with the percentage requested.
Here's what I did, but I immediately 0 in F9, but if I do the result in another cell, it goes well, but this is not the goal.

Code:
Private Sub ComboBox1_Change () 
If ComboBox1.Value = "0" Then 
Range ( "F9"). Formula = "= F9-(F9 * 0%)" 
ElseIf ComboBox1.Value = "5" Then 
Range ( "F9"). Formula = "= F9-(F9 * 5%)" 
ElseIf ComboBox1.Value = "10" Then 
Range ( "F9"). Formula = "= F9-(F9 * 10%)" 
ElseIf ComboBox1.Value = "15" Then 
Range ( "F9"). Formula = "= F9-(F9 * 15%)" 
End If 
End Sub
So is there a way to put this number in buffer or else?

BTW I am not in a userform! but directly on the sheet excel
Reply With Quote
  #2  
Old 13-02-2009
Member
 
Join Date: May 2008
Posts: 804
Re: How to change a percentage in a single cell ?

Normal, you say that the result of your cell = your cell less / plus the percentage.

Either you pass through an intermediate step like:
Depart | Percentage | Results

Or, you can not go through a formula (as the cell source is also the resulting cell) and that you will result in the cell, vba read:

Code:
Const val1 = 150 
Private Sub ComboBox1_Change () 
Range ( "F9"). Val1 = value * (1 - CDbl (ComboBox1.Value) / 100) 'no need for you if it takes the direct value in the combobox 
End Sub
The disadvantage is that you stored in a constant value, and not in your cell.

But the best is still to pass through an intermediate step because you want to keep in memory the number of departure.

Best regards
Reply With Quote
  #3  
Old 13-02-2009
Member
 
Join Date: Feb 2008
Posts: 767
Re: How to change a percentage in a single cell ?

yes indeed for the intermediate stage as if I calculate the 10% of the number then I want to deliver 0% or 15%, it is calculated on the number of start ...
But, how do I write an intermediate step?

I thought to copy the number in another cell is hiding? (if possible)
Reply With Quote
  #4  
Old 13-02-2009
Member
 
Join Date: May 2008
Posts: 804
Re: How to change a percentage in a single cell ?

Uh you watched my code?
There is a constant. So if you had fun changing a number in a hidden cell, all the change directly in your code.
Reply With Quote
  #5  
Old 13-02-2009
Member
 
Join Date: Feb 2008
Posts: 767
Re: How to change a percentage in a single cell ?

It's good I found, thank you
I copied my number to another cell and it goes perfectly.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to change a percentage in a single cell ?"
Thread Thread Starter Forum Replies Last Post
How to get multiple values of Vlookup in Single Cell Henriksen MS Office Support 4 25-02-2012 11:02 AM
Need help to get single quote in every cell of Excel Hache hi MS Office Support 2 23-02-2012 01:17 PM
How to get single apostrophe in cell of Excel AsceTic! MS Office Support 2 15-02-2012 05:06 PM
How to fix maximum text in single cell of Microsoft Excel Irritator MS Office Support 2 03-02-2012 07:47 PM
What Percentage of 3D games can be played with a single GeForce Gtx 570? Ham Monitor & Video Cards 10 27-09-2011 01:13 PM


All times are GMT +5.5. The time now is 05:25 PM.