Lock a cell format to dollars only

G

Guest

I've created a button linked to several calculations. It begins by
calculating a percentage. Then I figure the dollars with that figure. Then I
figure the difference between the original dollar amt and the new dollar amt.
Then I copy this into the cells I want it to stay. I have 4 buttons I'm using
to cover 4 possible scenarios. They're all set at "Percent - Dollar - Dollar"
(and they're all set up to run via macro tied to the buttons. Now, on some,
when I click the button it's changing my first dollar to a percent. Why would
it do that and how can I prevent it?
 
G

Guest

I have 3 buttons I've built using Macro's to initiate the actions.
Button 1 and Button 2 work perfectly.
Button 3 changes my first number from a $figure to a percentage.
It's weird.
I have one thought on why.
The sheet has been passed back and forth between windows and Mac.
Maybe it lost something in there.


Private Sub CommandButton1_Click()
'
' Calc1 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("O103").Select
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("O104").Select
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("P102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("P103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("P104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("O102:p104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Private Sub CommandButton2_Click()
'
' Calc2 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "=R[-93]C/(R12C-R11C)"
Range("Q103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C/(R12C-R11C)"
Range("Q104").Select
ActiveCell.FormulaR1C1 = "0%"
Range("R102").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("R103").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("R104").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("S102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("S103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("S104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("R102:S104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Private Sub CommandButton3_Click()
'
' Calc3 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "0%"
Range("T103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"
Range("T104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"
Range("U102").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("U103").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("U104").Select
ActiveCell.FormulaR1C1 = "=-R[-97]C[-1]"
Range("U104").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("V102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("V103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("V104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("U102:V104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("T12").Select

End Sub
 
G

Guest

Your 3rd macro set the Activecell to % so if this (active) cell contains your
$ data it will be set to %. However, in my testing if I set the Activecell
format to currency it didn't get changed but did if the format was GENERAL.



You could remove the SELECT statements and see if this makes any dfference:

Range("T103")..FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"

from

Range("T103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"

hth

Debbie said:
I have 3 buttons I've built using Macro's to initiate the actions.
Button 1 and Button 2 work perfectly.
Button 3 changes my first number from a $figure to a percentage.
It's weird.
I have one thought on why.
The sheet has been passed back and forth between windows and Mac.
Maybe it lost something in there.


Private Sub CommandButton1_Click()
'
' Calc1 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("O103").Select
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("O104").Select
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("P102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("P103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("P104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("O102:p104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Private Sub CommandButton2_Click()
'
' Calc2 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "=R[-93]C/(R12C-R11C)"
Range("Q103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C/(R12C-R11C)"
Range("Q104").Select
ActiveCell.FormulaR1C1 = "0%"
Range("R102").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("R103").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("R104").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("S102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("S103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("S104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("R102:S104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Private Sub CommandButton3_Click()
'
' Calc3 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "0%"
Range("T103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"
Range("T104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"
Range("U102").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("U103").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("U104").Select
ActiveCell.FormulaR1C1 = "=-R[-97]C[-1]"
Range("U104").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("V102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("V103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("V104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("U102:V104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("T12").Select

End Sub

Toppers said:
Difficult to determine without seeing the code; can you post it please.
 
G

Guest

Thanks for your help.
It's up and running.
I have one more question if you would be so kind.
Otherwise, I can post as a new thread.

When I "password protect" my worksheet, my buttons no longer work.
I get a run-time error 1004.
Any ideas why it would do this?

Toppers said:
Your 3rd macro set the Activecell to % so if this (active) cell contains your
$ data it will be set to %. However, in my testing if I set the Activecell
format to currency it didn't get changed but did if the format was GENERAL.



You could remove the SELECT statements and see if this makes any dfference:

Range("T103")..FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"

from

Range("T103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"

hth

Debbie said:
I have 3 buttons I've built using Macro's to initiate the actions.
Button 1 and Button 2 work perfectly.
Button 3 changes my first number from a $figure to a percentage.
It's weird.
I have one thought on why.
The sheet has been passed back and forth between windows and Mac.
Maybe it lost something in there.


Private Sub CommandButton1_Click()
'
' Calc1 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("O103").Select
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("O104").Select
ActiveCell.FormulaR1C1 = "=R7C[5]*R[-93]C[4]"
Range("P102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("P103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("P104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[1]-RC[-1]"
Range("O102:p104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Private Sub CommandButton2_Click()
'
' Calc2 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "=R[-93]C/(R12C-R11C)"
Range("Q103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C/(R12C-R11C)"
Range("Q104").Select
ActiveCell.FormulaR1C1 = "0%"
Range("R102").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("R103").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("R104").Select
ActiveCell.FormulaR1C1 = "=R7C[2]*RC[-1]"
Range("S102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("S103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("S104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-2]-RC[-1]"
Range("R102:S104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub

Private Sub CommandButton3_Click()
'
' Calc3 Macro
' Macro recorded 4/17/2006 by DBagby
'

'
ActiveCell.FormulaR1C1 = "0%"
Range("T103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"
Range("T104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-3]/(R12C[-3]-R9C[-3])"
Range("U102").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("U103").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("U104").Select
ActiveCell.FormulaR1C1 = "=-R[-97]C[-1]"
Range("U104").Select
ActiveCell.FormulaR1C1 = "=R7C[-1]*RC[-1]"
Range("V102").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("V103").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("V104").Select
ActiveCell.FormulaR1C1 = "=R[-93]C[-5]-RC[-1]"
Range("U102:V104").Select
Selection.Copy
Range("T9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("T12").Select

End Sub

Toppers said:
Difficult to determine without seeing the code; can you post it please.

:

I've created a button linked to several calculations. It begins by
calculating a percentage. Then I figure the dollars with that figure. Then I
figure the difference between the original dollar amt and the new dollar amt.
Then I copy this into the cells I want it to stay. I have 4 buttons I'm using
to cover 4 possible scenarios. They're all set at "Percent - Dollar - Dollar"
(and they're all set up to run via macro tied to the buttons. Now, on some,
when I click the button it's changing my first dollar to a percent. Why would
it do that and how can I prevent it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top