0

I am trying to copy a column of data from one workbook and paste its values to another workbook. I am able to just use regular copy paste, but when I try to paste values it returns blanks. I am new to VBA so there is maybe something I am missing with the syntax? Here is my code:

Sub ImportData()
    Dim FileLocation As String
    
    FileLocation = Application.GetOpenFilename
    If FileLocation = "False" Then
        Beep
        Exit Sub
    End If
    
    Application.ScreenUpdating = False
    Set ImportWorkbook = Workbooks.Open(Filename:=FileLocation)
    
    ImportWorkbook.Worksheets(2).Range("C4:D25").Copy ThisWorkbook.Worksheets(1).Range("A1")
    ImportWorkbook.Worksheets(2).Range("G4:G25").Copy
    Range("C1").PasteSpecial xlPasteValues
    
    ImportWorkbook.Close
    Application.ScreenUpdating = True
End Sub
BigBen
  • 38,994
  • 6
  • 24
  • 37
abigidiot
  • 11
  • 2
  • 1
    With `ImportWorkbook.Worksheets(2).Range("G4:G25")`, `ThisWorkbook.Worksheets(1).Range("C1").Resize(.Rows.Count).Value = .Value`, `End With`. Make sure to fully qualify `Range("C1")` with the workbook and worksheet, and it's better to just transfer the `.Value` directly, bypassing the clipboard. – BigBen Mar 02 '22 at 14:46

0 Answers0