当我的VBA脚本无法弄清楚如何调用"选定的工作表
我需要做什么:
从中复制一些数据并粘贴到当前打开的Excel中
Private Sub openDialog()
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = True
' Set the title of the dialog box.
.Title = "Please select the file."
' Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
'edit data
Range("K4").Select
ActiveCell.FormulaR1C1 = "=LEFT(RIGHT(R[-2]C[-10],65),20)"
Range("L4").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[5]C[-3]"
Range("M4").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[6]C[-4]"
Range("N4").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[7]C[-5]"
Range("O4").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[8]C[-6]"
' copy data
Range("K4:O4").Select
Selection.Copy
' paste on active cell
For i = 1 To LastRow
ws.Range ("A" & i)
ActiveSheet.PasteSpecial Paste:=xlPasteValues
Next i
'DO NOT KNOW WHAT TO USE HERE
End If
End With
End Sub