Cell Values change after connection closed

30percent

Board Regular
Joined
May 5, 2011
Messages
118
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have the following code to open connection to another workbook - copy a range and paste it to thisworkbook.
However, after paste and closing the connection, values/formulas from part of the range changed.

How could I prevent that aside from paste as values as I want to retain the formatting?

Thank you!

Code:
Sub import_Data(ByVal thisMonth As Integer, ByVal thisYear As Integer, ByVal thisDate As Date)
With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    
finalRow_Paste = ThisWorkbook.Worksheets("Sheet1").Cells(Sheets("Sheet1").Rows.Count, "a").End(xlUp).Row
Set rng_Paste = ThisWorkbook.Worksheets("Sheet1").Range("A" & finalRow_Paste + 2)


sessionDate = get_SessionDate(get_Minus_Day(), "Summary")
pathName = createPathName(get_Minus_Day(), "Summary") & "Summary " & sessionDate & ".xlsx"


Set wb = Application.Workbooks.Open(pathName)


finalRow_wb = wb.Worksheets("Summary").Cells(Sheets("Summary").Rows.Count, "F").End(xlUp).Row


Set wb_Copy = wb.Worksheets("Summary").Range("A1:F" & finalRow_wb)


wb_Copy.Copy Destination:=rng_Paste
Application.CutCopyMode = False


wb.Close False


pathName = ""
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
How could I prevent that aside from paste as values as I want to retain the formatting?

Pasting as values doesn't affect the formatting, it changes formulas to the formula result.
 
Upvote 0

Forum statistics

Threads
1,214,901
Messages
6,122,157
Members
449,068
Latest member
shiz11713

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