Hello Everyone,
I am new to VBA and was trying to write a VBA array code for some reason I keep getting asubscript out of range error
I would like VBA to calculate target sales in column E to be equal to the current SalesAmounts X 2 which in column D.
Option Explicit
Sub Arrytraining()
Dim SalesAmounts() As Variant
Dim i As Long, Dimension1 As Long
Dim SalesTraget() As Variant
SalesAmounts = Range("D2", Range("D2").End(xlDown))
Dimension1 = UBound(SalesAmounts, 1)
ReDim SalesTarget(1 To Dimension1)
For i = 1 To Dimension1
SalesAmounts(i, 1) = SalesTarget(i, 1) * 2 (This is where the error is)
Next i
Range("E2", Range("E2").Offset(Dimension1 - 1, 1)).Value = SalesTarget
End Sub
Your help is much appreciated
I am new to VBA and was trying to write a VBA array code for some reason I keep getting asubscript out of range error
I would like VBA to calculate target sales in column E to be equal to the current SalesAmounts X 2 which in column D.
Option Explicit
Sub Arrytraining()
Dim SalesAmounts() As Variant
Dim i As Long, Dimension1 As Long
Dim SalesTraget() As Variant
SalesAmounts = Range("D2", Range("D2").End(xlDown))
Dimension1 = UBound(SalesAmounts, 1)
ReDim SalesTarget(1 To Dimension1)
For i = 1 To Dimension1
SalesAmounts(i, 1) = SalesTarget(i, 1) * 2 (This is where the error is)
Next i
Range("E2", Range("E2").Offset(Dimension1 - 1, 1)).Value = SalesTarget
End Sub
Your help is much appreciated