我的研究員。 Matlab很酷,R也是如此,但現在是時候使用VBA Excel了。 我想在「Sheet2」(列A)中找到存儲在「Sheet1」(單元格A1)中的一個值。我可以使用Select和從一張紙跳到另一張紙,但我想這樣做沒有這個跳躍。我想運行我的代碼而不讓Excel在代碼運行時看起來狂熱。我希望它運行無關緊要,當我運行宏時,我已經在Excel中激活了該工作表。 這可能嗎?檢查我的代碼下面。 所有爲你們所有的最好的!找到方法沒有選擇或激活
Sub FindName()
Dim Name As String
Dim TablePosition As Range
Name = Worksheets("Sheet1").Range("A1").Value
'If I insert here: Worksheets("Sheet2").Select
'The codes runs but just because I am telling him to move to sheet2
'Why is it not going to Sheet2 with the instruction bellow?
With Worksheets("Sheet2").Application.Range("A1", Range("A1").End(xlDown))
Set TablePosition = _
.Find(What:=Name, _
After:=Range("A1").End(xlDown), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
Searchorder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not TablePosition Is Nothing Then
Application.Goto TablePosition, True
Else
MsgBox "Name not specified."
End If
End With
End Sub
高手解答。解決方案的理論解釋! – 2015-02-10 13:33:26