Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default VB calculations

Tim,

See code snippets in-line.

HTH,
Bernie
MS Excel MVP


"timmulla" wrote in message
...
Can anyone help me do the following calculations in a excel userform.

I have two calendar 10.0 controls (Calendar1 and Calendar2).
Calendar1.value relates to a start date and calendar2.value relates to an end
date. I'm trying to have the number of days between Calendar1 and Calendar2
show up in a conrtol labeledTextBox8, when Commandbutton1 is clicked.


Depends: something like:

Userform1.TextBox8.Text = Userform1.Calendar2.value - Userform1.Calendar1.Value
Userform1.TextBox8.Text = Userform1.Calendar2.value - Userform1.Calendar1.Value + 1

TextBox1 - Numerical user input expressed as a percentage (i.e. 10%,this is
a % fee charged on an account).

TextBox2 - Numerical user input expressed a dollar amount (i.e. $100,000,
this is account value).

TextBox3 - I'm trying to have the value of TextBox1.value * Texbox2.value
show up when Commandbutton1 is clicked.


UserForm1.TextBox3.Text = _
Format(Val(UserForm1.TextBox1.Text) / 100 * _
Val(UserForm1.TextBox2.Text), "00.00")


TextBox4 - I'm trying to have TextBox3.value/365 show up when Commandbutton1
is clicked (This will give me a daily rate).



UserForm1.TextBox4.Text = _
Format(Val(UserForm1.TextBox3.Text) / 365, "00.00")

TextBox5 - I'm trying to have TextBox8.value * TextBox5.value show up when
Commandbutton1 is clicked.


UserForm1.TextBox5.Text = _
Format(Val(UserForm1.TextBox8.Text) * _
Val(UserForm1.TextBox5.Text), "00.00")

Though be careful with this one... multiple clicks will give you problems.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default VB calculations

Tim,

Unless you have a relational database with thousands of records, you can use
Excel as your database. You could use code like this to store your data:

Dim myRow As Long

With Worksheets("DataBase")
myRow = .Cells(Rows.Count,1).End(xlUp)(2).Row
.Cells(myRow,1).Value = Val(Userform1.TextBox1.Text)
.Cells(myRow,2).Value = Val(Userform1.TextBox2.Text)
.Cells(myRow,3).Value = Val(Userform1.TextBox3.Text)
.Cells(myRow,4).Value = Val(Userform1.TextBox4.Text)
'Etc...
End With

And code like this to extract your data (with column A as the key value)

Dim myRow As Long

With Worksheets("DataBase")
myRow = Application.Match(Userform1.TextBox1.Text,.Range(" A:A"),False)
Userform1.TextBox2.Text = .Cells(myRow,2).Value
Userform1.TextBox3.Text = .Cells(myRow,3).Value
Userform1.TextBox4.Text = .Cells(myRow,4).Value
'Etc...
End With

Of course, you might need to format the data, and use error checking, etc.
to tell when you are modifying existing data versus adding new data...

HTH,
Bernie
MS Excel MVP


"timmulla" wrote in message
...
Thanks for your help Bernie, it's working great. Another question I was
hoping you could answer for me is:

Is it possible to have the textbox values recorded in an access data base
when a user clicks the Commandbutton1 on UserForm1? I'm hoping that the
textbox values can be stored in a data base as a record. I would also
like
to be able to retrieve the data base values back into UserForm1 upon a
listbox selection.

Is this possible? if so, can you recommend a good source of information to
show me how to accomplish this (website/book,etc..)

Thanks.



--
Regards,

timmulla


"Bernie Deitrick" wrote:

Tim,

See code snippets in-line.

HTH,
Bernie
MS Excel MVP


"timmulla" wrote in message
...
Can anyone help me do the following calculations in a excel userform.

I have two calendar 10.0 controls (Calendar1 and Calendar2).
Calendar1.value relates to a start date and calendar2.value relates to
an end
date. I'm trying to have the number of days between Calendar1 and
Calendar2
show up in a conrtol labeledTextBox8, when Commandbutton1 is clicked.


Depends: something like:

Userform1.TextBox8.Text = Userform1.Calendar2.value -
Userform1.Calendar1.Value
Userform1.TextBox8.Text = Userform1.Calendar2.value -
Userform1.Calendar1.Value + 1

TextBox1 - Numerical user input expressed as a percentage (i.e.
10%,this is
a % fee charged on an account).

TextBox2 - Numerical user input expressed a dollar amount (i.e.
$100,000,
this is account value).

TextBox3 - I'm trying to have the value of TextBox1.value *
Texbox2.value
show up when Commandbutton1 is clicked.


UserForm1.TextBox3.Text = _
Format(Val(UserForm1.TextBox1.Text) / 100 * _
Val(UserForm1.TextBox2.Text), "00.00")


TextBox4 - I'm trying to have TextBox3.value/365 show up when
Commandbutton1
is clicked (This will give me a daily rate).



UserForm1.TextBox4.Text = _
Format(Val(UserForm1.TextBox3.Text) / 365, "00.00")

TextBox5 - I'm trying to have TextBox8.value * TextBox5.value show up
when
Commandbutton1 is clicked.


UserForm1.TextBox5.Text = _
Format(Val(UserForm1.TextBox8.Text) * _
Val(UserForm1.TextBox5.Text), "00.00")

Though be careful with this one... multiple clicks will give you
problems.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MPG Calculations Terry Bennett Excel Worksheet Functions 8 June 10th 08 10:17 PM
age calculations Tulip Excel Discussion (Misc queries) 2 July 8th 07 07:29 PM
#N/A in calculations JonR Excel Worksheet Functions 6 September 10th 06 07:33 PM
Help with calculations Scoooter Excel Worksheet Functions 1 June 19th 06 03:19 PM
! in Calculations Strata Excel Discussion (Misc queries) 4 December 14th 05 01:15 PM


All times are GMT +1. The time now is 12:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"