Macro change from 2007 to 2010

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Macro change from 2007 to 2010

Post by VegasNath »

Hi,
Moving from Excel 2007 on Windows XP to Excel 2010 on Windows 7, I am experiencing an issue with the following code – It just stalls at the paste formats line and refuses to continue….

'Update Reconciliation
wb1.Sheets("V+ Reports").Cells.Copy
wb0.Sheets("V+ Reports").Range("A1").PasteSpecial Paste:=xlPasteValues
wb0.Sheets("V+ Reports").Range("A1").PasteSpecial Paste:=xlPasteFormats

I have tried adjusting to the following in the hope activation / sheet selection might help, but no difference.

'Update Reconciliation
wb1.Sheets("V+ Reports").Cells.Copy
wb0.Activate
wb0.Sheets("V+ Reports").Select
wb0.Sheets("V+ Reports").Range("A1").PasteSpecial Paste:=xlPasteValues
wb0.Sheets("V+ Reports").Range("A1").PasteSpecial Paste:=xlPasteFormats



Any idea’s please?
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro change from 2007 to 2010

Post by HansV »

It shouldn't be necessary to activate the workbook and to select the sheet.

Is wb1 a .xls workbook and wb0 a .xlsx/.xlsb/.xlsm workbook, or vice versa?
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Macro change from 2007 to 2010

Post by VegasNath »

Hi Hans, thought that myself but felt worth a try.... Both are xlsm.
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro change from 2007 to 2010

Post by HansV »

Does it work better if you change

wb1.Sheets("V+ Reports").Cells.Copy

to

wb1.Sheets("V+ Reports").UsedRange.Copy
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Macro change from 2007 to 2010

Post by VegasNath »

Unfortunately not.
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro change from 2007 to 2010

Post by HansV »

There must be something else going on that has nothing to do with Excel 2007/2010. Has either of the worksheets involved been changed in another way - merging cells, or something like that?
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Macro change from 2007 to 2010

Post by VegasNath »

No. I bypassed the line and had the same issue with the next set of sheets.

So i switched back to 2007 win XP and it worked fine.

Does not make any sense : (
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Macro change from 2007 to 2010

Post by HansV »

VegasNath wrote:Does not make any sense : (
I don't understand it either. The changes from Excel 2007 to Excel 2010 aren't large...
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Macro change from 2007 to 2010

Post by Rudi »

I too am baffled at why this code is freezing?

how about another approach?

Code: Select all

    wb1.Sheets("V+ Reports").Copy Before:=wb0.Sheets(1)
    wb0.Sheets(1).UsedRange.Value = wb0.Sheets(1).UsedRange.Value
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.