设置一个要粘贴区域的输入框



我在YouTube上看了这个视频,它真的帮了我很多,现在我必须改进代码。在代码中粘贴值的那一行我必须设置inputbox之类的,让用户选择要粘贴的地方。下面是我的代码:

Sub IMPORT_DATA()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files(*.xlsx),*xlsx")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets("NELT report").Range("R7:R14").Copy
ThisWorkbook.Worksheets("Dispatch Monthly NETO").Range("L5").PasteSpecial xlPasteValues
OpenBook.Close False
Range("L5:L12").Interior.Color = RGB(255, 242, 204)
End If
Application.ScreenUpdating = True
End Sub
Sub IMPORT_DATA()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Dim s As String ' Range to Paste
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import 
Range", FileFilter:="Excel Files(*.xlsx),*xlsx")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets("NELT report").Range("R7:R14").Copy
s = InputBox("Range to Paste : ")
If s = "" Then Exit Sub
ThisWorkbook.Worksheets("Dispatch Monthly NETO").Range(s).PasteSpecial 
xlPasteValues
OpenBook.Close False
Range("L5:L12").Interior.Color = RGB(255, 242, 204)
End If
Application.ScreenUpdating = True
End Sub

相关内容

  • 没有找到相关文章

最新更新