VB脚本提取单元格值并存储在单独的文件中

时间:2018-12-12 16:53:00

标签: excel

我想运行一个vb脚本从每张工作表中提取一个特定的单元格值并将其粘贴到新的工作簿中,除此之外,该值还可以存在于单独的excel文件中

Sub Macto()
' Create Excel object
Set objExcel = CreateObject("Excel.Application")
' Open the workbook
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\Users\x.pr\Desktop\vbscript.xlsx")
' Set to True or False, whatever you like
objExcel.Visible = True

' Select the range on Sheet1 you want to copy
objWorkbook.Worksheets("Sheet1").Range("A11:C11").Copy
' Paste it on Sheet2, starting at A1
objWorkbook.Worksheets("Sheet2").Range("A1").PasteSpecial
' Activate Sheet2 so you can see it actually pasted the data
objWorkbook.Worksheets("Sheet2").Activate
End Sub

0 个答案:

没有答案