willyboy58
Technical User
I have the following info in my Clntrate table:
(the actual table has about 300 people listed)
Number Name Rate
1000 Bob 2.50
1250 Steve 1.25
1500 Mike 3.00
1569 Frank 4.50
I am wanting to select and move some of this info over to 3 different hours and pay sheets. I have the following code for the move:
Sub aVLookUpCopied()
Range("B2"
.Select
With Range("B2"
'B2 is for the Name
.Value = "=VLOOKUP(A2, [propxfer.xls]clntrate!$A$2:$C$99, 2, FALSE)"
End With
Selection.AutoFill Destination:=Range("B2:B99"
, Type:=xlFillDefault
'C2 is for the Rate
Range("C2"
.Select
With Range("C2"
.Value = "=VLOOKUP(A2, [propxfer.xls]clntrate!$A$2:$C$99, 3, FALSE)"
End With
Selection.AutoFill Destination:=Range("C2:C99"
, Type:=xlFillDefault
End Sub
The info moves as desired, but then when I run the following procedure to calculate total pay, I get a “Type Mismatch” error message on the 9th person on the FIRST sheet. When I look at the first spreadsheet, the first 8 people calculate as desired, but starting at the 9th, on the spreadsheet I get #NA on down in the name and rate columns (B and C) and my total’s column (AF) stops calculating on the 8th employee. On sheets 2 and 3, I get about half way down and then get the #NA. There is no calculation of the total pay on the 2nd and 3rd sheets yet, so I don’t have any totals.
Sub Calcdollars()
Dim Calcdollars As Single
Range("A2"
.Select
Do
With Activecell
‘the following line is highlited during the error
Calcdollars = .Offset(0, 2) * (.Offset(0, 28) + .Offset(0, 29))
.Offset(0, 31) = Calcdollars
.Offset(1, 0).Select
End With
Loop Until Activecell = ""
Range("AE7"
.Select
End Sub
Three questions: 1) Why am I getting a Type Mismatch error? 2) Why does it calculate for the first 8 and not for the rest? There are no empty fields in the clntrate sheet. 3) How can I change the line .Value = "=VLOOKUP(A2, [propxfer.xls]clntrate!$A$2:$C$99, 3, FALSE)" to select all the “current region “ instead of just A2:C99? All info is exported from another program into Excel and more info is added every month and a hard coded range isn’t practical.
TIA
Bill
(the actual table has about 300 people listed)
Number Name Rate
1000 Bob 2.50
1250 Steve 1.25
1500 Mike 3.00
1569 Frank 4.50
I am wanting to select and move some of this info over to 3 different hours and pay sheets. I have the following code for the move:
Sub aVLookUpCopied()
Range("B2"
With Range("B2"
'B2 is for the Name
.Value = "=VLOOKUP(A2, [propxfer.xls]clntrate!$A$2:$C$99, 2, FALSE)"
End With
Selection.AutoFill Destination:=Range("B2:B99"
'C2 is for the Rate
Range("C2"
With Range("C2"
.Value = "=VLOOKUP(A2, [propxfer.xls]clntrate!$A$2:$C$99, 3, FALSE)"
End With
Selection.AutoFill Destination:=Range("C2:C99"
End Sub
The info moves as desired, but then when I run the following procedure to calculate total pay, I get a “Type Mismatch” error message on the 9th person on the FIRST sheet. When I look at the first spreadsheet, the first 8 people calculate as desired, but starting at the 9th, on the spreadsheet I get #NA on down in the name and rate columns (B and C) and my total’s column (AF) stops calculating on the 8th employee. On sheets 2 and 3, I get about half way down and then get the #NA. There is no calculation of the total pay on the 2nd and 3rd sheets yet, so I don’t have any totals.
Sub Calcdollars()
Dim Calcdollars As Single
Range("A2"
Do
With Activecell
‘the following line is highlited during the error
Calcdollars = .Offset(0, 2) * (.Offset(0, 28) + .Offset(0, 29))
.Offset(0, 31) = Calcdollars
.Offset(1, 0).Select
End With
Loop Until Activecell = ""
Range("AE7"
End Sub
Three questions: 1) Why am I getting a Type Mismatch error? 2) Why does it calculate for the first 8 and not for the rest? There are no empty fields in the clntrate sheet. 3) How can I change the line .Value = "=VLOOKUP(A2, [propxfer.xls]clntrate!$A$2:$C$99, 3, FALSE)" to select all the “current region “ instead of just A2:C99? All info is exported from another program into Excel and more info is added every month and a hard coded range isn’t practical.
TIA
Bill