Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Calculating values in VB

  Asked By: Kaua    Date: Dec 13    Category: MS Office    Views: 759
  

I am very green with VB and I've created a button that when it's
clicked, it will display results of the entered data in a box on the
screen. What I am having an issue with is displaying the data in the
correct format. I want to display StdDeviation and SigmaM as .0123
but it shows as 1.233339388. Also I want all of the others to be no
longer than 4 decimal places. How do I specify this in the code?
Thanks in advance for any assistance you may be able to offer!
Snow

Private Sub CommandButton1_Click()

Calc
RunSummaryForm.AverageRun12 = Worksheets("Sheet1").Cells(19, 8)
RunSummaryForm.Run1Average = Worksheets("Sheet1").Cells(18, 7)
RunSummaryForm.Run2Average = Worksheets("Sheet1").Cells(18, 8)
RunSummaryForm.DeltaAverage = Worksheets("Sheet1").Cells(19, 6)
RunSummaryForm.SigmaM = Worksheets("Sheet1").Cells(20, 8)
RunSummaryForm.MaxDelta = Worksheets("Sheet1").Cells(21, 6)
RunSummaryForm.StdDeviation = Worksheets("Sheet1").Cells(20, 6)

RunS

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Shayne Anderson     Answered On: Dec 13

First it looks as though you need to divide your answer by 100 unless the cell
format is currently set to percent.

Then use Round(yourformula,4)

 
Answer #2    Answered By: Ludano Ricci     Answered On: Dec 13

try:

RunSummaryForm.StdDeviation = FormatNumber(Worksheets("Sheet1").Cells
(20, 6),4)

 
Didn't find what you were looking for? Find more on Calculating values in VB Or get search suggestion and latest updates.




Tagged: