1

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

子 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

结束子

4

0 回答 0