1

重新提出问题:我使用了一个范围(包含标题)来定义一个数组,我对其进行了初始化并从表中提取了数据。事情进展顺利(有冗余和重复的代码),但我可以直接将数组写入 Excel 行。

但是代码需要验证和初始化,因此我迁移到一个封装这两个要求的类。动态实现需要用InsertLines.

问题是,现在我有一个类中的数据,但我不知道如何将它写入单行。

以前的算法:

Dim MyRange as Range
Dim sTR() as string

'set myrange to a specific range of cells'
'Redim the sTR array to match the number of unique variables in the range
'Extract values from multiples rows in a table to the sTR array'
'Write the array to the Excel file with:' 
MyRange.Offset(x, y).value = sTR()

当前方式:

Dim MyRange as Range

'set myrange to a specific range of cells (Nine columns and variable rows)'
'InsertCode into a class module with all unique values in the range as public variables
Dim sTR as ClassX
Set sTR as New ClassX

'Extract values from multiples rows in a table to the sTR Class'

现在的问题是,我不知道类中变量的顺序(这与前面的数组方法没有问题,但这种方法肯定涉及太多的代码冗余)。

请帮忙!想知道一个变量是否可以用不同的名称(别名)来解决,这可以解决我的问题。或者有没有办法解决一个类中的所有公共变量(比如循环)?

4

0 回答 0