PDA

View Full Version : move sheets without links



av8tordude
10-06-2011, 10:41 AM
I have this code that move 2-3 sheets from wbk A to wbk B. I have a formulas in 8 cells that references a cell in sheet 1. The code works as expected but for some reason the formulas in the sheets 2 -3 still references the old workbook. I don't want any references to the old workbook. Its my understanding that UpdateLinks:=False is to prevent links to the old workbook. Can someone assist

On Error GoTo 0
'set variable to the current workbook
Set old_wbk = ActiveWorkbook
'set variable to new downloaded workbook - this needs to point to the new file that was downloaded.
Set new_wbk = Workbooks.Open(frmVersion.txtFile, UpdateLinks:=False)

For Each wks In old_wbk.Worksheets
If wks.Name Like "####" Then 'check if sheet name is a four digit number.
If (CInt(wks.Name) >= 2009) Then 'check if sheet name is a year between 2009 and 2020.
wks.Move Before:=new_wbk.Worksheets("f2106") 'move the worksheet to the new workbook
End If
End If
Next