简体   繁体   中英

Paste values but retain existing formulas

This is my first post so Hello and please bear with me. I'm new to VBA and learning as I go.

Currently I copy and paste values of a sheet (Deal Input) from source workbook (wbA) to destination (wbB). The sheets (Deal Input) matche in the two workbooks. However I want to retain the formulas in one specific column (AA) of wbB. I would like this to trigger based on “Paste”.

I've seen incomplete code that will paste values excluding locked cells as an option and in that case column (AA) could be locked. Other option I've seen would be to paste values excluding any formulas with “=“ as the cell identifier given column AA has the formulas I wish to retain.

Is there a more straightforward solution and is anyone familiar with pasting values of a sheet from one wb to another but retaining the existing formulas for a specific range within the destination wb?

You'll want to use .PasteSpecial(xlPasteFormulas)

For a detailed explanation see this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM