在vba中填充矩阵

时间:2013-07-24 16:23:36

标签: matrix populate

我尝试从工作表中的三列填充矩阵。我的代码应该在第一列中找到一个值,将其与y轴匹配,然后在第二列中搜索一个值,将其与x轴中的列标题匹配,然后粘贴第三列中的值由行/列匹配激活的单元格中的列。有没有人看到我的代码有什么问题?我一直得到一个"对象变量或者没有设置块变量"错误:

Sub Button1_Click() Application.ScreenUpdating = False

Dim filePath As String
Dim strDate As String
Dim strMatchJE As String
Dim strMatchComponent As String
Dim wSheet As Worksheet
Dim wBook1 As Workbook

Set wSheet = ThisWorkbook.Sheets("Sheet1")

'Activate Journal Entry Number
strMatchJE = Columns("A").Find(what:="", after:=wSheet.Cells(1, 1), LookIn:=xlValues).Activate
aString = Left(originalString, 1)

strMatchJE = wSheet.Cells.Find(what:=aString, after:=Wbook.Cells(1, 1), _
            LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
            SearchDirection:=xlNext, MatchCase:=True).Address

'Activate component
strMatchComponent = Columns("B").Find(what:="", after:=wSheet.Cells(1, 1), LookIn:=xlValues).Activate
bString = Left(originalString, 1)

strMatchJE = wSheet.Cells.Find(what:=aString, after:=Wbook.Cells(2, 1), _
            LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, _
            SearchDirection:=xlNext, MatchCase:=True).Address

strEnterAmount = Columns("T").Find(what:="", after:=wSheet.Cells(3, 1), LookIn:=xlValues).Activate

firstrow = ActiveCell.Row
firstcolumn2 = ActiveCell.Column

firstrow = firstrow + 1

Rows(firstrow).Columns(firstcolumn2).Select
strEnterAmount.Paste

End Sub

0 个答案:

没有答案