ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete all Links via VBA (https://www.excelbanter.com/excel-programming/443381-delete-all-links-via-vba.html)

Seanie

Delete all Links via VBA
 
How can I delete all links/range names within a range of sheets? I
extract and Copy Paste Special values via below, but it retains links
to the source document (which I don't need)

Thanks

Sourcewb.Sheets(Array("Report1", "Report2", "Report3")).Copy
Set Destwb = ActiveWorkbook

For Each sh In Destwb.Worksheets
sh.Select
With sh.UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
Destwb.Worksheets(1).Select
Next sh

Kevin Vivian

Delete all Links via VBA
 

In article
s.com, Seanie writes
How can I delete all links/range names within a range of sheets? I
extract and Copy Paste Special values via below, but it retains links
to the source document (which I don't need)

Thanks

Sourcewb.Sheets(Array("Report1", "Report2", "Report3")).Copy
Set Destwb = ActiveWorkbook

For Each sh In Destwb.Worksheets
sh.Select
With sh.UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
Destwb.Worksheets(1).Select
Next sh



Instead of the line -

".Cells.PasteSpecial xlPasteValues"

try this -

..Cells.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

It worked for me on a similar project.

Cheers

--
Kevin


All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com