VBA calc using a named cell

scottishmovies

Board Regular
Joined
Mar 11, 2003
Messages
158
Hi Guys,

I'm a bit stumped (Again!)

I have a cell on a sheet (Settings) named "SALES" and a User Form on another sheet (Data) called UserForm1 with a TextBox which get a number from the user called TextBox10.

Everything works great except that I now want to do a calculation to return to the Data sheet ie TextBox10 * SALES which would hopefully return the calulation of the qty in TextBox10 multiplied by the figure on the Settings sheet caleld SALES - but I can't figure it out - any ideas?

I've tried: Datasheet.Cells(CurrentRow, 10).Value = TextBox10 * SALES
but no luck :( where am I going wrong?

Regards,
Pat
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try

Code:
Datasheet.Cells(CurrentRow, 10).Value = Val(TextBox10.Value) * Range("SALES").Value
 
Upvote 0
Hi Peter,

Thanks for the very quick reply. I'm getting an error:

Run Time error '424'
Object required

Do I need to define the sheet (Settings) beforehand or in the range?

Pat
 
Upvote 0
I assume that DataSheet is an object variable that you have assigned a sheet to. If it is the name of a sheet you would need

Code:
Sheets("Datasheet").Cells(CurrentRow, 10).Value = Val(TextBox10.Value) * Range("SALES").Value
 
Upvote 0
Went back to basics and set up a new form with your first code in it - and it worked so I suspect I must have something else causing me problems.

But now that I know what to put in for it work - thank you! Much appreciated!

Pat
 
Upvote 0

Forum statistics

Threads
1,224,513
Messages
6,179,214
Members
452,895
Latest member
BILLING GUY

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
Back
Top