As @sktneer rightly suggested in my previous query to read data into an Array when dealing with large data.
I want to Read through an array of Range A to the end and if the value in A1 is equal to "L" then add B1 + C1
I am converting this formula to below code =IF(A1="Male",C1+D1,FALSE)
Sub ANewMacro()
Dim lr As Long, i As Long, j As Long
Dim c, d, x, y()
lr = Cells(Rows.Count, 1).End(xlUp).Row
x = Range("A1:A" & lr).Value
c = Range("C1:C" & lr).Value
d = Range("D1:D" & lr).Value
ReDim y(1 To UBound(x, 1), 1 To 1)
j = 1
For i = 1 To UBound(x, 1)
If x(i, 1) = "L" Then
y(i, 1) = c(i, 1) + d(i, 1)
j = j + 1
ElseIf x(i, 1) = "S" Then
y(i, 1) = c(i, 1) + d(i, 1)
j = j + 1
Else
y(i, 1) = "NULL"
j = j + 1
End If
Next i
Range("B1").Resize(UBound(y), 1).Value = y
End Sub
The code works as desired but wanted to know if the method of declaring multiple range is correct and also the execution.
I have to loop through 100 000 rows