Harshil Mehta
Board Regular
- Joined
- May 14, 2020
- Messages
- 85
- Office Version
- 2013
- Platform
- Windows
The code gives an error before pasting if the array is empty. What could be the best solution to bypass if there is not data store in the array?
Nary is out of subscription.
'
Nary is out of subscription.
'
VBA Code:
Find and add matched cases into another array
ReDim Nary(1 To UBound(Ary), 1 To c)
For r = 1 To UBound(Ary)
If InStr(1, Trim(LCase(Ary(r, SourceCol))), CountryKey, vbTextCompare) > 0 Then
nr = nr + 1
For c = 1 To UBound(Ary, 2)
Nary(nr, c) = Ary(r, c)
Next c
End If
Next r
'Paste data from the array to Destination Sheet
With OpenDestination
With .Sheets(DestinationSheet)
'.Range("A2").Resize(nr, UBound(Nary, 2))
With .Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(nr, UBound(Nary, 2))
.NumberFormat = "@" 'Text format
.Value = Nary
.NumberFormat = "General"
End With