Copying Between Workbooks with VBA

courtneyjh

New Member
Joined
Oct 27, 2014
Messages
1
Hello,

I have recently (in the last month) started using VBA for a work project. My goal is to copy the values of certain cells in one workbook and paste them into what will become a Database like file. The macros were written where the destinations are links. I can break the links and the data becomes values but unfortunately if the original file is opened anytime the destination file is opened it will clear all cells linked even if I chose to "not update" them. I think my only choice will be to rewrite the macro so that it is more of a copy and paste rather than a link. The macro reads as follows....

Sub CopyToProductionReport()
'
' CopyToProductionReport Macro
'
'
'

'-----<<<<<<< change file location >>>>>>>--------"
If Not IsFileOpen("H:\00 Production Reporting\DO NOT OPEN ---- Production Reporting Database.xlsx") Then
newLine = LineName()
Workbooks.Open "H:\00 Production Reporting\DO NOT OPEN ---- Production Reporting Database.xlsx", UpdateLinks:=0

Dim vTotal_Row, vCurrent_row, vCurrent_column_p, vCurrent_column_d As Integer

'---------------------------------------------------------------------

Sheets("Sheet1").Select
vCurrent_row_d = Application.Run("FindNextRow")

vCurrent_column_d = 1
vCurrent_column_p = 1
Application.StatusBar = "Total row:" & vCurrent_row_d & " Processing row:" & vCurrent_row_s

'****************** shift 1 info
Sheets("Sheet1").Cells(vCurrent_row_d, vCurrent_column_d).Value = "='[" & newLine & ".xlsm]Data'!R17C3" 'a year
Sheets("Sheet1").Cells(vCurrent_row_d, vCurrent_column_d + 1).Value = "='[" & newLine & ".xlsm]Data'!R17C1" 'b month linked to A16
Sheets("Sheet1").Cells(vCurrent_row_d, vCurrent_column_d + 2).Value = "='[" & newLine & ".xlsm]Data'!R17C4" 'c week linked to D16
Sheets("Sheet1").Cells(vCurrent_row_d, vCurrent_column_d + 3).Value = "='[" & newLine & ".xlsm]Data'!R17C2" 'd day linked to B16

'-----<<<<<<< change file location >>>>>>>--------"
MsgBox "Copy to production report Complete"
ActiveWorkbook.SaveAs FileName:= _
"H:\00 Production Reporting\DO NOT OPEN ---- Production Reporting Database.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=True
ActiveWorkbook.Close True


Application.Run ("ClearSheet")

Else
result = MsgBox("Please close production database report", vbOKOnly + vbCritical, "Abort Encounterd")

End If

End Sub






Any suggestions on how to fix this? A rewrite? or an addition that will keep the links from updating?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,216,026
Messages
6,128,363
Members
449,444
Latest member
abitrandom82

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