Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
gerhardl
Creator II
Creator II

Macro to change excel formulas to values

Hello,

If I have the following macro code that exports data to excel, then adds a formula, and the autofills teh formula to the last row:

ActiveDocument.GetSheetObject("TB01").CopyTableToClipboard true

XLSheet2.Paste XLSheet2.Range("A1")

XLApp.Worksheets(2).Range("F:F").Insert

LastRow = XLSheet2.Range("A65535").End(-4162).Row

XLSheet2.Range("F1") = "Card No"

XLSheet2.Range("F2").Formula = "=concatenate(D2,E2)"

XLSheet2.Range("F2").AutoFill XLSheet2.Range("F2:F"& LastRow)


I am now stuck with the formulas in excel - how can I change them to just the values? I've tried this paste special but it does't seem to work. It keeps pasting the formula:

XLApp.Range("F2:F"& LastRow).Select

XLApp.Selection.Copy

xlSheet2.Range("G2").PasteSpecial  Paste = xlPasteValues




1 Reply
gerhardl
Creator II
Creator II
Author

Nevermind, this works:

xlSheet2.Range("G2").PasteSpecial -4163