Forum Discussion
Veraborn64
Aug 10, 2020Copper Contributor
Filling in blank cells with values from another workbook
Hello all, I'm looking for help writing a macro which does the following but struggling with a few areas, I'd like to do the following: 1) Identify all blank cells in a given range. All blank ce...
PeterBartholomew1
Aug 10, 2020Silver Contributor
This outlines an approach that load values to an from the workbook(s) as a block and sorts the data transfer between arrays held in memory.
Option Explicit
Option Base 1
Sub transfer()
Dim vSource
Dim vDestination
Dim i As Long, j As Long
Dim v
' Load Source and Destination ranges into variant arrays
vSource = [Source].Value
vDestination = [Destination].Value
' Loop over elements of array copying values to empty locations
For i = 1 To UBound(vDestination, 1)
For j = 1 To UBound(vDestination, 2)
v = vDestination(i, j)
If v = vbEmpty Then _
vDestination(i, j) = vSource(i, j)
Next j
Next i
' Return augmented array to destination range
[Destination].Value = vDestination
End Sub