1

I am having trouble pasting.

I have written the code but when it gets to cell and selects it I have tried putting paste in but still does not work.

Code below, the starred bit is the issue

Sheets("Data").Select
If Range("A2") = "" Then
  Range("A1").Paste
Else
  Selection.End(xlDown).Select
  ActiveCell. Offset(0, 1).Select
  With Range("A" & Rows.Count).End(xlUp).Offset(1)
  End With
  ActiveSheet.Range("$D$1:$D$50000").AutoFilter Field:=6, Criteria1:="B"
  lastrow = Range("D" & Rows.Count).End(xlUp).Row
  Range("D:M").SpecialCells(xlCellTypeVisible).Select
  Set Rng = ActiveSheet.AutoFilter.Range
  Windows("Pull Back Scans.xlsm").Activate
  Sheets("Data").Select
  If Range("A2") = "" Then
    Range("A1").Paste
  Else
    Selection.End(xlDown).Select
    ActiveCell.Offset(0, 1).Select
    With Range("A" & Rows.Count).End(xlUp).Offset(1)
    End With
    **ActiveSheet.PasteSpecial**
    Columns("A:J").Select
    Columns("A:J").EntireColumn.AutoFit
    Windows("Belfast CDC Scans.xlsb").Activate
    ActiveWorkbook.Close savechanges:=False
  End If
  Columns("A:J").Select
  Columns("A:J").EntireColumn.AutoFit
  Windows("Belfast CDC Scans.xlsb").Activate
  ActiveWorkbook.Close savechanges:=False
End If
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Wheatus
  • 11
  • 1
  • 2
    Which kind of "trouble" do you have? What should this code do, and what happens instead? – Nico Haase Jun 26 '18 at 12:31
  • 1
    You might want to take a look at: [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – Vincent G Jun 26 '18 at 12:36

0 Answers0