Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I assign variables
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) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
Storing variables in a macro and using those variables to performcalculations. | Excel Programming | |||
Assign different | Excel Programming | |||
assign | Excel Discussion (Misc queries) | |||
Assign a variables value to a TextBox | Excel Programming |