VBE313
Well-known Member
- Joined
- Mar 22, 2019
- Messages
- 686
- Office Version
- 365
- Platform
- Windows
in the following code, I am trying to Extract just the "Y" numbers. My code gives me the answer I need, but the array UDF uses 2 columns. I only want my answer to be in column E not column F. What am I doing wrong?
VBA Code:
Option Explicit
Function getY(rng As Range)
Dim i As Integer, j As Integer, n As Integer
Dim temp As Integer, A()
n = rng.Rows.Count
ReDim A(n, 1)
A = rng
For j = 1 To n
If A(j, 2) = "Y" Then
temp = A(j, 1)
A(j, 2) = ""
Else
A(j, 1) = ""
A(j, 2) = ""
End If
Next j
getY = A
End Function