0

I have this formula, which takes two numbers in two cells, performs a division and places the value into a cell. However, this method causes the output to be a integer value.

wsProt.Range("E" & pdTableCount).Value = wsProt.Range("F" & pdTableCount).Value / wsProt.Range("D" & pdTableCount).Value

Is there a way to do this that will cause the value to be a value that provides for a decimal part without having to use an intermediary variable?

Also, I don't want the cell to be a formula, I just want the actual value for the division.

thanks!

tincanfury
  • 63
  • 3
  • 9
  • Format cell to include decimals? – findwindow May 27 '16 at 15:09
  • You could use the `.NumberFormat` property to specify the exact number of decimal places: http://stackoverflow.com/questions/20648149/what-are-numberformat-options-in-excel-vba – Tim May 27 '16 at 15:14
  • `.Value` isn't an `Integer`, it's a `Variant` (https://msdn.microsoft.com/en-us/library/office/ff195193.aspx), the output of your algorithm will only be an `Integer` if the quotient is a whole number, otherwise it'll be a `Double`. If you think the result should be a `Double` but you're not seeing one, then the problem probably lies in your cell formatting. – Ambie May 27 '16 at 17:14
  • will you supply the actual values so we can double check? – S Meaden May 27 '16 at 18:26
  • well now I'm just annoyed. I turned on my my laptop this morning, opened up the spreadsheet, ran it again to see how the cell format affects the situation and now the number being placed in the cell contains the full expected decimal without having changed anything. – tincanfury May 31 '16 at 13:13

0 Answers0