我正在为一个工作项目工作,我碰到了一堵墙。我正试图自动化一些格式来加速进程。在Sheet1上,有一个G2到W21的表格。包含在此表中的数据由用户通过用户窗体输入。数据输入后,我使用这些数据驱动Sheet2格式化。到目前为止,我已经想出了如何处理这张表的列G & H我想要的方式。我无法弄清楚如何处理列I:M和O:W。Excel VBA:显示数组?
下面是代码,我拿出这么远:
Dim LineItems As Range, Cell As Range
Dim linearr() As Variant
Dim datasetarr() As Variant
Dim i As Integer
Dim j As Integer
Dim accountnum As Range
Dim accountnumrng As Range
Set LineItems = Sheet1.Range("H2:H21")
Set DataSets = Sheet1.Range("G2:G21")
For Each Cell In LineItems
If Len(Cell.Value) > 0 Then
i = i + 1
ReDim Preserve linearr(1 To i)
linearr(i) = Cell.Value
End If
Next Cell
For Each Cell In DataSets
If Len(Cell.Value) > 0 Then
j = j + 1
ReDim Preserve datasetarr(1 To j)
datasetarr(j) = Cell.Value
End If
Next Cell
Set accountnumrng = Sheet2.Range("B6:B1000").SpecialCells(xlCellTypeConstants, 23)
For Each accountnum In accountnumrng.Cells
accountnum.Offset(1, 1).Cells(1, 1).Resize(UBound(linearr), 1).Value = Application.Transpose(linearr)
accountnum.Offset(1, 0).Cells(1, 1).Resize(UBound(datasetarr), 1).Value = Application.Transpose(datasetarr)
Next accountnum
这里是在Sheet1表的图片。概述红色是我试图用
我基本上只是想什么我到目前为止想通了扩大合作的列。任何帮助将不胜感激。
你能告诉什么是Sheet2的此刻看起来像一张照片? –
看起来您正在超越电子表格的正常使用。你问的问题可以很容易地处理,但是随着时间的推移,我认为你会希望你已经在数据库应用程序或数据库支持的内部网上完成了这个任务。考虑一下需要添加什么东西或将工作簿合并以获得年度数字的道路。只是一个想法... – Beengie
@ScottCraner我刚刚添加了几张图片 –