I have two columns of data in a spreadsheet. Column A has either cells containing "X" or empty cells and Column B contains formulas. I want to use VBA to pull Column A into an array, and paste the array into Column B, making sure the "X"s copy over but the empty array elements do not.
The method I have looks at each array element and if it is an "X" then paste that 1 element, it works but its slow for large data pools. Is there a faster method?
See code below:
Option Explicit
Sub Test()
Dim array1 As Variant, i As Integer
array1 = Sheets("Sheet1").Range("A2:A8").Value
For i = 1 To UBound(array1)
If array1(i, 1) = "X" Then
Sheets("Sheet1").Cells(i + 1, 2) = array1(i, 1)
End If
Next i
End Sub
B
be converted to values or do the formulas have to stay intact? – VBasic2008