[COLOR=blue]Function TableToArray(ByVal TableName As String)[/COLOR]
[COLOR=blue]Dim arr[/COLOR]
[COLOR=blue]Dim vRange As Range[/COLOR]
[COLOR=blue]Dim i As Long, j As Long, m As Long, n As Long[/COLOR]
[COLOR=blue]If Not RangeNameExists(TableName) Then Exit Function 'Neu khong ton tai thi thoat[/COLOR]
[COLOR=blue]On Error Resume Next[/COLOR]
[COLOR=blue]Set vRange = Range(TableName)[/COLOR]
[COLOR=blue]i = vRange.Rows.Count[/COLOR]
[COLOR=blue]j = vRange.Columns.Count[/COLOR]
[COLOR=blue]ReDim arr(1 To i, 1 To j)[/COLOR]
[COLOR=blue]For m = 1 To i[/COLOR]
[COLOR=blue]For n = 1 To j[/COLOR]
[COLOR=red]If IsNumeric(vRange(m, n).Value) Then[/COLOR]
[COLOR=red]arr(m, n) = Format(vRange(m, n).Value, "#,##0")[/COLOR]
[COLOR=red]Else[/COLOR]
[COLOR=red]arr(m, n) = vRange(m, n).Value[/COLOR]
[COLOR=red]End If[/COLOR]
[COLOR=blue]Next n[/COLOR]
[COLOR=blue]Next m[/COLOR]
[COLOR=blue]TableToArray = arr[/COLOR]
[COLOR=blue]Set vRange = Nothing[/COLOR]
[COLOR=blue]End Function[/COLOR]