Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
HI
New to VB and trying to write a program that gets two values from cells and calculates a column of values. cell "C19" = 4.0938 cell "C21" = 4.8438 ========================= Sub FillInRange() Dim intK As Long Dim intT As Long Dim intX As Long Dim intY As Long intX = Range("C19").Value intY = Range("C21").Value intT = Range("C15").Value Range("L28").Select For I = 1 To (intT - 1) Step 1 intK = intX + (intY * I) Selection.Value = intK ActiveCell.Offset(1, 0).Select Next End Sub ======================= But in the program they appear as C19 = 4 C21 = 5 Is there a way to get the decimal value into the variables? Sorry if this dosen't make to much sense as I am not sure of the terms to use. Jim |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
New to VB and trying to write a program that gets two values from
cells and calculates a column of values. cell "C19" = 4.0938 cell "C21" = 4.8438 ========================= Sub FillInRange() Dim intK As Long Dim intT As Long Dim intX As Long Dim intY As Long intX = Range("C19").Value intY = Range("C21").Value intT = Range("C15").Value Range("L28").Select For I = 1 To (intT - 1) Step 1 intK = intX + (intY * I) Selection.Value = intK ActiveCell.Offset(1, 0).Select Next End Sub ======================= But in the program they appear as C19 = 4 C21 = 5 Is there a way to get the decimal value into the variables? Although you say C19=4 and C21=5, I am guessing your complaint is intX=4 and intY=5 because of your last sentence above. If that is the case, the problem is you declared these variables as Longs... a Long can only hold whole numbers. Declare them as Single or Double, depending on precision requirements and, assuming I am right in my assumptions, all should be as you want it. Rick |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 24, 7:15 pm, "Rick Rothstein \(MVP - VB\)"
wrote: Although you say C19=4 and C21=5, I am guessing your complaint is intX=4 and intY=5 because of your last sentence above. If that is the case, the problem is you declared these variables as Longs... a Long can only hold whole numbers. Declare them as Single or Double, depending on precision requirements and, assuming I am right in my assumptions, all should be as you want it. Rick Yes, Thanks that fixed the problem. Values are now what I wanted.. Jim |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Function to put worksheet name in cell returns text, need number | Excel Discussion (Misc queries) | |||
Format for Whole number and 1 Decimal in same Cell | Excel Worksheet Functions | |||
Function that returns the page number a cell falls on | Excel Worksheet Functions | |||
number returns only two decimal places after I change from text | Excel Discussion (Misc queries) | |||
I want to format a number cell without the decimal and without ro. | Excel Discussion (Misc queries) |