Sub MRP()
Dim rng, Rng1 As Range
Dim str As String
Static totalrow2 As Integer
Dim a, i, j, k, totalrow1, totalcol As Integer
Sheets(2).Cells.Select
Selection.AutoFilter
MsgBox ("here")
totalrow1 = Sheets(1).[B65536].End(xlUp).Row
totalrow2 = Sheets(2).[B65536].End(xlUp).Row
totalcol = Sheets(2).Range("IV1").End(xlToLeft).Column
num2name = Replace(Cells(1, totalcol).Address(0, 0), "1", "")
arr = Sheets(2).Range("a2:mun2name" & totalcol).SpecialCells(xlCellTypeVisible).Value
不知道为什么最后一行运行不了,如果改成具体数(比如“a2:bi81")就可以运行。同时msgbox打印mun2name和totalcol的值分别为bi,81.
run-time error'1004': application-defined or object-defined error