View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default How do I assign variables

Hi

First, an integer variable can only hold integer values. As the result
of your calculation may result in a decimal value, declare the
resulting variable as Double.

Second, I am not sure what you are trying to do with the statement
below....


paycode1=Cells(j, 12).Formula = Cells(j, 7) * Cells(j, 11)


Hopes this helps.
....
Per


On 10 Aug., 02:37, "KevinM" wrote:
Hi. *I'm new to VBA and wrote this code to calculate pay. *It's working but
what I also need is to have calculations done by taking the data and adding
them and then dividing them. *I wanted to assign varibles to the IF
statements to allow me make the addition and division easier but its not
working. *How do I assign variables to allow me to add and divide? *Here is
the code. *Thank you in advance.

Sub calculate_retropay()



* * Dim paycode12 As Integer
* * Dim paycode13 As Integer
* * Dim paycode1E As Integer
* * Dim paycode1H As Integer
* * Dim paycode1I As Integer
* * Dim paycode1J As Integer
* * Dim paycode1 As Integer

* * 'this will search for the pay period in column C
* * Enterpp = InputBox("Please enter the period number ie 2008-21-0")
* * finalrow = Cells(65536, 3).End(xlUp).Row
* * finalrow1 = Cells(65536, 6).End(xlUp).Row

* * For i = 1 To finalrow
* * For j = 1 To finalrow1

* * 'takes the value of what pay period is keyed in
* * If Cells(i, 3).Value = Enterpp Then
* * 'if paycode =1 then take the new rate * by hours
* * If Cells(j, 6).Value = 1 Then
* * *paycode1=Cells(j, 12).Formula = Cells(j, 7) * Cells(j, 11)
***when I assign this as a variable it doesn't work
* * *Else
* * *If Cells(j, 6).Value = 5 Then
* * *Cells(j, 12).Value = "test" * * * * * * * * * ** if its set like this
when it works fine
* * Else
* * if paycode =12 then take the new rate * by hours
* * If Cells(j, 6).Value = 12 Then
* * * Cells(j, 12).Formula = Cells(j, 7) * Cells(j, 11)