文件复制并粘贴空白数据(或甚至不复制和粘贴)。加载也很长

时间:2016-05-19 15:53:59

标签: excel vba excel-vba

有人可以告诉我为什么数据没有复制和粘贴(或者为什么要复制和粘贴空白数据?还有办法加速自动化吗?

 Sub GetDataCopyPaste()

 Dim wbTarget As Workbook 'where the data will be pasted
 Dim wbSource As Workbook 'where the data will be copied
 Dim StrName As String 'name of the source sheet

 Application.ScreenUpdating = False 'these statements help performance by disabling the self titled in each, remeber to re-enable at end of code
 Application.DisplayAlerts = False

 Set wbTarget = ActiveWorkbook 'set to the current workbook
 StrName = ActiveSheet.Name 'get active sheetname of workbook


 Set wbSource = Workbooks.Open("C:\Users\jjordan\Desktop\Test Dir\Test File Test\metrics list.xlsx") 'opens Target workbook

 Set wbTarget = Workbooks.Open("C:\Users\jjordan\Desktop\Test Dir\MASTER\Weekly Logbook - 2016.xlsm") 'opens Source workbook

 wbSource.Sheets("IOS").Range("A1:E60").Value = wbTarget.Sheets("Sheet6").Range("A1:E60").Value 'copy & pastes source data onto Target workbook

 wbTarget.Save 'save workbook

 Application.ScreenUpdating = True
 Application.DisplayAlerts = True

 End Sub

1 个答案:

答案 0 :(得分:1)

这一行是向后的

private void mod() {
    Player p = playersService.loadById(1L);
    p.setNick("OtherNick");
    playerService.updatePlayer(p);
}

Then in PlayerService

@Transactional
public void updatePlayer(Player player){
   session.merge(player);
}

你需要

 wbSource.Sheets("IOS").Range("A1:E60").Value = wbTarget.Sheets("Sheet6").Range("A1:E60").Value 'copy & pastes source data onto Target workbook

我刚刚测试并成功了

 wbTarget.Sheets("Sheet6").Range("A1:E60") = wbSource.Sheets("IOS").Range("A1:E60").value