0
當我將「lFundcolumn」中的「Activesheet.cells」替換爲「rnMonths」時,出現「運行時錯誤13」。如果有人能夠解釋我在這裏做錯了,我會很感激。設置區域內的查找/查找
簡而言之 - 我想在行內找到一個值,並將該列和該列的右側複製。以下是查找錯誤的第一列的代碼。
Sub Roll_period()
Dim sMonth As String
Dim rnMonths As Range
Dim lFundcolumn As Long
Dim rnRngtocopy As Range
sMonth = ActiveSheet.Cells(3, 1).Value
Set rnMonths = ActiveSheet.Rows(4)
lFundcolumn = rnMonths.Find(What:=sMonth, after:=ActiveCell, LookIn:=xlValues, LookAt:=xlWhole, searchorder:=xlByColumns).Column
John的回答將解決您的問題,但我也建議在檢查'.Column'屬性前檢查'.Find()'的返回值,否則當找不到該值時會出錯因爲Find()將返回Nothing而不是Range對象) – 2013-03-25 16:11:52