Copy data from another but Row formulas should not be changed

AnilKumar141

New Member
Joined
Jul 3, 2024
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi,

I have created a file where daily data will be updated with new data. (Both are same format with same # rows & columns)
As per the below screen shot, highlighted rows are formula.
Can I replace the new data in this file without changing the formula rows.
Both files having same # of rows.

If i copy the data , only rows with out formula to be changed .Can it be done?

1720020261112.png
 

Attachments

  • 1720020017652.png
    1720020017652.png
    7.2 KB · Views: 4

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi, I hope you can use macros.
Such one shall do the job very quickly.
You shall have both files open (is new datatable in a separate workbook? I assumed it is), and file with data to be replaced active.
I also assumed your tables starts with cell A1, and that workbook with new data has has only one worksheet (or data is on first worksheet).

If you are not familiar with macros read this first: How to create, change, copy and delete VBA macros in Excel - especially part "Write or insert code in the VBA Editor"

VBA Code:
Sub test()
Dim tarr As Variant, sarr As Variant, i As Long, j As Long, lr As Long, lc As Long
lr = Range("A1").End(xlDown).Row
lc = Range("A1").End(xlToRight).Column
tarr = Range("A1").Resize(lr, lc).Formula
sarr = Workbooks("new_file.xlsx").Sheets(1).Range("A1").Resize(lr, lc).Formula
For i = 1 To lr
  For j = 1 To lc
    If Left(tarr(i, j), 1) <> "=" Then tarr(i, j) = sarr(i, j)
Next j, i
Range("A1").Resize(lr, lc).Formula = tarr
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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