ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help (https://www.excelbanter.com/excel-programming/343138-help.html)

saziz[_18_]

Help
 

I am trying to write a code to calculate efficiency of a process. Th
following code gives me "Object Required' Error Please educate me.

Private Sub CommandButton1_Click()
Dim NetLoad As Variant
Dim AveCoatWt As Variant
Dim WtGain As Variant
Dim solutionapplied As Variant

NetLoad.Value = TextBox1.Text

AveCoatWt.Value = TextBox2.Text
WtGain.Value = TextBox3.Text
solutiionapplied.Value = TextBox4.Text
TextBox5.Value = (TextBox4 / ((TextBox1 * TextBox2 * 1000000)
TextBox3))


End Sub

Thank you for your help.
Sye

--
sazi
-----------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...nfo&userid=635
View this thread: http://www.excelforum.com/showthread.php?threadid=47720


saziz[_19_]

Help
 

Thank you Bruce for correction of typo. That did not helped.
How should I define solutionapplied?
Thanks
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=477205


saziz[_20_]

Help
 

Please see my original post.
Thank you
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=477205


Dave Peterson

Help
 
You declared these things:

Dim NetLoad As Variant
Dim AveCoatWt As Variant
Dim WtGain As Variant
Dim solutionapplied As Variant

But you never set them to anything.

What are they?

saziz wrote:

I am trying to write a code to calculate efficiency of a process. The
following code gives me "Object Required' Error Please educate me.

Private Sub CommandButton1_Click()
Dim NetLoad As Variant
Dim AveCoatWt As Variant
Dim WtGain As Variant
Dim solutionapplied As Variant

NetLoad.Value = TextBox1.Text

AveCoatWt.Value = TextBox2.Text
WtGain.Value = TextBox3.Text
solutiionapplied.Value = TextBox4.Text
TextBox5.Value = (TextBox4 / ((TextBox1 * TextBox2 * 1000000) *
TextBox3))

End Sub

Thank you for your help.
Syed

--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=477205


--

Dave Peterson

saziz[_22_]

Help
 

Hi Dave,
The values for those are being input through textboxes.
Sye

--
sazi
-----------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...nfo&userid=635
View this thread: http://www.excelforum.com/showthread.php?threadid=47720


Dave Peterson

Help
 
Then those things are just holders for the values from the textboxes?

If yes, then each of those things will hold a string -- until/unless you convert
it to something else. And since you're doing arithmetic with them, maybe...

Private Sub CommandButton1_Click()
Dim NetLoad As double
Dim AveCoatWt As double
Dim WtGain As double
Dim solutionapplied As double

NetLoad = cdbl(TextBox1.Text)
AveCoatWt = cdbl(TextBox2.Text)
WtGain = cdbl(TextBox3.Text)
solutionapplied = cdbl(TextBox4.Text)

TextBox5.Value = (TextBox4 / ((TextBox1 * TextBox2 * 1000000) * TextBox3))

End Sub

These are simple variables--not objects (like ranges, which have a .value
property).

saziz wrote:

Hi Dave,
The values for those are being input through textboxes.
Syed

--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=477205


--

Dave Peterson

saziz[_23_]

Help
 

Dave,
Thank you for the help.
What could be the format for % for textbox5 value?
I am trying this:
textbox5.text=format( formula, "%")
It gives me error.
Thnaks once again for your help.
Syed


--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=477205


saziz[_24_]

Help
 

Dave,
Thank you for the help.
What could be the format for % for textbox5 value?
I am trying this:
textbox5.text=format( formula, "%")
It gives me error.
Thnaks once again for your help.
Sye

--
sazi
-----------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...nfo&userid=635
View this thread: http://www.excelforum.com/showthread.php?threadid=47720


Dave Peterson

Help
 
Maybe...

textbox5.text=format( formula, "0.00%")

And you may not need those intermediate variables, too:

Option Explicit

Private Sub CommandButton1_Click()

TextBox5.Value _
= Format((Me.TextBox4.Value _
/ ((Me.TextBox1.Value * Me.TextBox2.Value * 1000000) _
* Me.TextBox3.Value)), "0.0%")

End Sub

But I would add some checks for numbers for each of those textboxes.

saziz wrote:

Dave,
Thank you for the help.
What could be the format for % for textbox5 value?
I am trying this:
textbox5.text=format( formula, "%")
It gives me error.
Thnaks once again for your help.
Syed

--
saziz
------------------------------------------------------------------------
saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350
View this thread: http://www.excelforum.com/showthread...hreadid=477205


--

Dave Peterson


All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com