1

I have a problem with copying columns from one sheets to another. In the source of the worksheet, some of the cells are integrated with formula which are only calculated upon opening the workbook. Because of it, the result I end up copying from one workbook to another are the initial value. I have tried some of the solution but It doesn't work properly.

My code:

Application.Calculation = xlCalculationAutomatic

Set wb = Application.Workbooks.Open(FilePath, ReadOnly:=True, UpdateLinks:=0)

    If Not Application.CalculationState = xlDone Then
        DoEvents
    End If

wb.Sheets("Unified").Columns("A").Copy activeWB.Sheets("report").Range("A1")

For more information, this is the formula of a cell from the source worksheet:

"=VLOOKUP(B649,'filesystem'!$A:$N,14,FALSE)"

And the result I gotten is #REF!

Cœur
  • 37,241
  • 25
  • 195
  • 267
De De De De
  • 326
  • 3
  • 10
  • 31

1 Answers1

1

You are copying the formula, not the result.Try

Set SourceRange = Intersect(wb.Sheets("Unified").Columns("A"), wb.Sheets("Unified").UsedRange)
Set TargetRange = activeWB.Sheets("report").Range("A1").Resize(SourceRange.Rows.Count,1)
TargetRange.Value = SourceRange.Value
Excel Developers
  • 2,785
  • 2
  • 21
  • 35