1
我是一個使用VBA的完全新手,但已經成功地將以下代碼拼湊在一起,這適用於我的工作表中已將代碼分配給命令按鈕的工作表。我的問題是,我的工作表有超過3000行,我真的不想創建3000個按鈕。Excel 2010 VBA腳本
我目前的想法是有一個腳本搜索特定條件的單元格範圍(即真),然後運行我的原始代碼作爲與條件匹配的每個單元格的下標。我試圖創建一個循環來匹配正在搜索的條件,但不知道如何將結果設置爲活動單元格。
任何人都可以給我一些指示,如何實現這一點或提出更好的解決方案? 謝謝。
Sub Send_FWU_to_E_Drive()
Dim aTemp As String
Dim bTemp As String
Dim cTemp As String
Dim dTemp As String
Dim eTemp As String
Dim subdir As String
aTemp = "c:\test\"
bTemp = "E:\romdata\"
cTemp = ActiveCell.Offset(, -5) & ".fwu"
dTemp = ActiveWorkbook.path
eTemp = "\Firmware files"
subdir = "\Firmware Files\" & ActiveCell.Offset(, -5) & "\" & ActiveCell.Offset(, -5) & ".fwu"
MsgBox "The path of the active workbook is " & dTemp & subdir
If Dir(dTemp & subdir) = "" Then
MsgBox "Please check the file and ensure it is suitable for firmware updating with an SD card."
Exit Sub
End If
MsgBox "The file " & cTemp & " is being copied to " & bTemp
If Dir("e:\romdata", vbDirectory) = "" Then MkDir "E:\romdata"
If Dir(bTemp & "nul") = "" Then
MsgBox "The Destination Directory is missing, please ensure your SD Card is formatted, mapped as drive E and has a romdata directory."
Exit Sub
End If
FileCopy dTemp & subdir, bTemp & cTemp
End Sub
+ 1,用於暗示將細胞傳遞給函數。也許''找到'而不是循環? http://www.siddharthrout.com/2011/07/14/find-and-findnext-in-excel-vba/ –
@ SiddharthRout,完成。 –
感謝您的幫助,使我的項目變得更加簡單。 – user2282503