Reputation: 1
I have two sheets. When the second is activated I need to read the first and insert info into the second. The code below should do this but it is reading the second sheet,"Cabinet install", instead of the first. What is wrong?
Dim k As Integer
Dim j As Integer
Dim Sumknobs As Integer
Dim Cabsht As Worksheet
Dim Installsht As Worksheet
Set Cabsht = Worksheets("Cabinets")
Set Installsht = Worksheets("Cabinet Install")
Application.ScreenUpdating = True
Cabsht.Activate
With Worksheets("Cabinets")
For j = 1 To 4
For k = 1 To 46
Sumknobs = Sumknobs + .Cells(k + 4, 5 * j - 2) * Cells(k + 4, 5 * j - 1)
Next k
Next j
For j = 1 To 2
For k = 1 To 71
Sumknobs = Sumknobs + .Cells(k + 4, 5 * j + 18) * Cells(k + 4, 5 * j + 19)
Next k
Next j
End With
Installsht.Cells(17, 6) = Sumknobs
Upvotes: 0
Views: 37
Reputation: 96753
You are missing some . 's
Replace:
Sumknobs = Sumknobs + .Cells(k + 4, 5 * j - 2) * Cells(k + 4, 5 * j - 1)
with:
Sumknobs = Sumknobs + .Cells(k + 4, 5 * j - 2) * .Cells(k + 4, 5 * j - 1)
same for the second loop-set.
Upvotes: 1