When I am on the sheet named "Paste Sheet" the code works as expected. On any other sheet it gives me the Run-time error.
I am unsure as to what I am doing wrong as I am fairly new to VBA.
Calculation Code: ` Sub Calculations()
Dim table As Range, calcTable As Range, nextEmptyCell As Range
Dim name As String, sku As String, inventoryToOrder As Integer
Dim sum As Integer
Dim inStoreInventory As Integer
Dim onlineInventory As Integer
Dim reorderPoint As Integer
Dim rowNum As Integer
Set table = Sheets("Paste Sheet").Range("A2", Range("A2").End(xlToRight).End(xlDown))
For Each Row In table.Rows
name = Row.Cells(1, 7).Value
sku = Row.Cells(1, 3).Value
inventoryToOrder = Row.Cells(1, 29).Value
inStoreInventory = Row.Cells(1, 27).Value
onlineInventory = Row.Cells(1, 31).Value
sum = inStoreInventory + onlineInventory
reorderPoint = Row.Cells(1, 28).Value
If sum < reorderPoint Then
Worksheets("Calculations").Range("A2").Value = name
Worksheets("Calculations").Range("B2").Value = sku
Worksheets("Calculations").Range("C2").Value = inventoryToOrder
End If
Next Row
End Sub
`
I am trying to run a simple calculation on a worksheet ("Paste Sheet") and grab certain values like the Name, SKU, and Inventory to Order and paste all of those values in the worksheet called calculations.
The error is preventing me from moving forward and I am unsure how to get around it.