vba: copy&paste to a new workbook

waldymar

Board Regular
Joined
Feb 19, 2009
Messages
238
Dear All,

I created a macro which copy a spreadsheet and paste it as values in a new workbook:
Code:
[FONT=Calibri][SIZE=3]Sub Moving()[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Application.ScreenUpdating = False[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Dim varPath As String[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Dim WbOpen As Workbook[/SIZE][/FONT]<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>[FONT=Calibri][SIZE=3] [/SIZE][/FONT]</o:p>
[FONT=Calibri][SIZE=3]Set WbOpen = Workbooks.Add[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]varPath = coding.Range("b1").Value[/SIZE][/FONT]
<o:p>[FONT=Calibri][SIZE=3][/SIZE][/FONT]</o:p>
[FONT=Calibri][SIZE=3]bonddashboard.Copy before:=WbOpen.Sheets(1)[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]      [/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Application.DisplayAlerts = False[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]WbOpen.SaveAs varPath & "\Fixed Income Dashboard-" & Format(Date, "dd-mmm-yyyy") & ".xlsx"[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Application.DisplayAlerts = True[/SIZE][/FONT]
<o:p>[FONT=Calibri][SIZE=3] [/SIZE][/FONT]</o:p>
[FONT=Calibri][SIZE=3]Cells.Select[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Selection.Copy[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Application.CutCopyMode = False[/SIZE][/FONT]
<o:p>[FONT=Calibri][SIZE=3] [/SIZE][/FONT]</o:p>
[FONT=Calibri][SIZE=3]WbOpen.Close savechanges:=True[/SIZE][/FONT]
[FONT=Calibri][SIZE=3]Application.ScreenUpdating = True[/SIZE][/FONT]<o:p>[FONT=Calibri][SIZE=3] [/SIZE][/FONT]</o:p>
[FONT=Calibri]End Sub[/FONT]

Can anyone help me to develop a macro such as be able to copy (from the same old one) and paste as values a 2nd or 3rd spreadsheet (into the same a new one).
I would appreciate any help.
 
No, that would attempt to break the links for every sheet.
You can put those two lines just before that loop as it only needs to be done once.
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
No, that would attempt to break the links for every sheet.
You can put those two lines just before that loop as it only needs to be done once.

Very strange. It works well with 3 graphs and doesn't work with other 3. Basically, for the first 3 the series keeps only values. And the for the last 3 it delete the series at all, hence, showing only 1 dot ...
Do you have any idea how to fix it?
 
Upvote 0
Step through the code and see if gives any error messages.
Do you have any error trapping in place (i.e. on error goto statements)?
 
Upvote 0
if you don't mind can we fix it tomorrow? i have to leave my work, but i need to fix it and i wish you can help me on that!
i really appreciate your time! without you i would progress so much in such short time! thanks a lot!
 
Upvote 0
Step through the code and see if gives any error messages.
Do you have any error trapping in place (i.e. on error goto statements)?

Good Morning!
What do you exactly mean by "on error goto statements"? Actually, it doesn't give any error, it just applies differently the code for graphs.
 
Upvote 0
I found this code which pastes graph as pictures. Can you help me to incorporate it in our code please?

Sub CopyChartasPicture()
ActiveSheet.Copy
ActiveChart.ChartArea.Select
ActiveChart.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Selection.Clear
ActiveChart.Paste
End Sub
 
Upvote 0
You don't need that bit and from your previous post, you obviously don't have error trapping.
Best idea so far is to step through the code and check each graph's series just before and just after the breaklinks statement.
Let me know how you get on with that.
 
Upvote 0
You don't need that bit and from your previous post, you obviously don't have error trapping.
Best idea so far is to step through the code and check each graph's series just before and just after the breaklinks statement.
Let me know how you get on with that.

My friend,
I'm totally lost, I have the same set of graphs, but for some it works but for others it doesn't. I step through the code and checked each graph's series just before and just after. In the same conditions it gives me different results. Is there any way I can send you my sheet in order you can look at it with your expertize? I don't want to bother you so much, but I'm lost.
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top