我在下面的代碼中設置x不起作用。 Set f所做的很奇怪。我不知道爲什麼,我在我的代碼中間,這根本不起作用。我的觀點與Set f相同。任何想法爲什麼?Object required vba
Sub Macro2()
Dim WsOuput As Worksheet
Dim WsScenarios As Worksheet
Dim ScenarioIDrow As Long
Dim ScenarioIDColumn As Long
Dim ScenarioIDinScenarios As Long
Dim ScenarioIDinScenariosC As Long
Dim p As String
Dim q As String
Dim x As Range
Dim z As String
Dim r As String
Dim RgnScenarioOutput As Range
Dim RgnScenarioScenario As Range
Dim Findsomething As Range
Dim FindAgain As Range
Dim lLastRow As Long
Dim f As Range
Dim fAgainAddress As Range
Set WsOutput = Worksheets("Output")
Set WsScenarios = Worksheets("Scenarios.New")
lLastRow = WsOutput.Cells(Rows.Count, "B").End(xlUp).Row
r = WsOutput.Cells(lLastRow, 2).Address(RowAbsolute:=False, ColumnAbsolute:=False)
Range("B22").Select
Selection.Copy
Sheets("Scenarios.New").Select
Columns("A:A").Select
Set f = Selection.Find(What:=Worksheets("Output").Range("B22").Value, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
f.Select
q = f.Address
Set x = Cells.FindNext(After:=ActiveCell).Activate
x.Select
z = x.Address
Range("F21:M21").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Output").Select
Range("AFI35").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
End Sub
是'Cells.FindNext(後:= ActiveCell).Activate'返回一個對象? –
FindNext.Activate是正確的語法嗎? – Chrismas007
您應該重寫所有這些,而不是訴諸於'.Select'和'.Activate' –