本文介绍了在工作簿中导出所选的Excel工作表&使用out宏保存默认loaction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

希望一切顺利,

我有一个excel工作簿,里面有多张(例如,sheet1,sheet2,sheet3,sheet4 ....)。

I have a excel workbook, In that have multiple sheets (eg. sheet1, sheet2, sheet3, sheet4....).

问题是:

在该工作簿中,用户表单中包含选项按钮,如" .Export sheet1& 2,.Export Sheet3& 4,.Export All"

In that workbook have user form with option button present like ".Export sheet1 & 2 , .Export Sheet3 & 4, .Export All " .

我正在寻找,一旦我选择了" .Export sheet1& 2"选项按钮,需要导出特定的纸张1& 2(在同一工作簿中)工作簿名称应预定义为SH1& 2,在默认位置C:\
导出(c:文件夹也需要像"导出数据"一样拥有)。

Herewith I'm looking for, Once i selected the ".Export sheet1 & 2" option button, need to be export particular sheet 1 & 2 (in same work book) workbook name should predefined as SH1& 2, Export on default location C:\ (c: folder also need to be as own as "export data").

相同; .Export sheet3& 4"也。

如果我选择全选选项按钮,则需要导出sheet1& 2作为一本书和sheet3& 4作为不同的工作簿,在默认位置为c :( c:文件夹也需要像"导出数据"一样自己)。

If i Select the select all option button, need to be export sheet1 & 2 as one book and sheet3 & 4 as different work book, on default location as c:(c: folder also need to be as own as "export data").

 

请任何人都可以帮助我。

Please any one can help me on this.

 

推荐答案

 

   范围("B26")。选择

   表格(数组("Sheet1","Sheet2"))。选择

   表格("Sheet2")。激活

   表格(数组("Sheet1","Sheet2"))。复制

  

    Range("B26").Select
    Sheets(Array("Sheet1", "Sheet2")).Select
    Sheets("Sheet2").Activate
    Sheets(Array("Sheet1", "Sheet2")).Copy
  

UI然后对录制的宏进行了一些小的更改 当您使用COPY并且未指定目的地位置时,Excel会自动生成新工作簿

UI then made some minor changes to the recorded macro.  When you use COPY and don't specify a destination locationj excel automatically generates a new workbook

  

   表格(数组("Sheet1","Sheet2"))。复制

   设置bk1 = ActiveWorkbook

    bk1.SaveAs文件名:=" c:\ temp \ booka.xls"
$
   表格(数组("Sheet1","Sheet2"))。复制

   设置bk2 = ActiveWorkbook

    bk2.SaveAs文件名:=" c:\ temp \ bookb.xls"

  
    Sheets(Array("Sheet1", "Sheet2")).Copy
    Set bk1 = ActiveWorkbook
    bk1.SaveAs Filename:="c:\temp\booka.xls"
    Sheets(Array("Sheet1", "Sheet2")).Copy
    Set bk2 = ActiveWorkbook
    bk2.SaveAs Filename:="c:\temp\bookb.xls"

 

如果你不知道新工作簿然后使用thjis代码

If you don't wnat a new workbook then use thjis code

    表格(数组("Sheet1","Sheet2"))。复制_
$
       after:= Sheets(Sheets.Count)



$
 

     Sheets(Array("Sheet1", "Sheet2")).Copy _
       after:=Sheets(Sheets.Count)


 


这篇关于在工作簿中导出所选的Excel工作表&使用out宏保存默认loaction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 22:55