本帖最后由 lss001 于 2021-12-7 11:12 编辑
Sub 加至数组第1列() '注意行数相同
ar = [{"片区";"姓名";"电话";"属性";"采购";"区域";"状态";"数量"}] '1列用分号间隔***
br = [{1,2;3,4;5,6;7,8;1,2;3,4;5,6;7,8}] '二维
Set sh = CreateObject("excel.sheet") '创建对象
With sh.ActiveSheet
x = UBound(ar) '获取各数组行列数
y = UBound(br): y1 = UBound(br, 2)
.[a1].Resize(x, 1) = ar '写入第1列
.[b1].Resize(y, y1) = br '写入第2列
arr = .[a1].Resize(y, 1 + y1) '读取
End With
sh.Close '关闭对象
End Sub
Sub 加至数组第1行() '注意列数相同
ar = [{"片区","姓名","电话","属性","采购","区域","状态","数量"}] '1行用逗号间隔***
br = [{1,2;3,4;5,6;7,8;1,2;3,4;5,6;7,8}] '二维
Set sh = CreateObject("excel.sheet") '创建对象
With sh.ActiveSheet
x = UBound(ar) '获取各数组行列数
y = UBound(br): y1 = UBound(br, 2)
.[a1].Resize(1, x) = ar '写入第1行
.[a2].Resize(y, y1) = br '写入第2行
arr = .[a1].Resize(y + 1, y1) '读取
End With
sh.Close '关闭对象
End Sub
|