Formulas don't work in a userform

Jim Stewart

New Member
Joined
Oct 18, 2006
Messages
14
Erdinç E. Karaçam gave me some formulas to total columns on a different sheet and when the information is entered manually, they work great. However, when I enter them thru a userform, they don't work.
formulas:
=Count(Sheet1!A:A)
=Sum(Sheet1!A:A)

Can anyone help?
Thanks in advance.
Jim
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hello Jim,
How are you trying to enter these?
Something like this will work.
Code:
Private Sub CommandButton1_Click()
Sheets("Sheet2").[B1].Formula = "=Count(Sheet1!A:A)"
Sheets("Sheet2").[C1].Formula = "=Sum(Sheet1!A:A)"
End Sub

This anything close to what you're wanting to do?
 

Jim Stewart

New Member
Joined
Oct 18, 2006
Messages
14
I'm enmtering them as a formula in a cell. I think I've found the problem if you can help. When the cells are filled from a userform, they are entered as text. Is there a way to make the userform convert them to n umbers?
Thanks,
Jim
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Are they coming from a textbox or something in the userform?
And do you want them entered as the actual formulas, or as static values of what the
formulas would return?

Also, can we see the code you're using to enter them?
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Again, can we see the code you're currently using for your commandbutton?

When I call up a userform with a combo & textbox I can have a list of formulas in the
ListFillRange for the combobox - entered like so: '=COUNT(Sheet1!A:A) - and then type
a formula into the textbox - like so: =Sum(Sheet1!A:A) - and with the following code:
Code:
Private Sub CommandButton1_Click()
Sheets("Sheet2").[B1].Formula = ComboBox1.Text
Sheets("Sheet2").[C1].Formula = TextBox1.Text
End Sub
it puts the live formulas into the ranges specified.

Is this what you're trying to do?
If not then can you explain further?
 

Forum statistics

Threads
1,140,921
Messages
5,703,175
Members
421,280
Latest member
Jaycee01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top