2

Why the code below pastes nothing? It actually copies what I want, but the paste operation doesn´t work.

With Workbooks(NomeAmostra)
     Range("B55").Copy
End With

     Workbooks("Recuperar (simplificada)").Sheets("DadosProcessados").Activate
       Range("AG" & n).PasteSpecial Paste:=xlValues 'Colagem dos resultados
         Set Horario = Range("AG" & n)
            Horario = Left(Horario, Len(Horario) - 4)

I´ve changed it and now it works just fine, but I don´t understand the reason.

Workbooks(NomeAmostra).Activate
Range("B55").Copy

  Workbooks("Recuperar (simplificada)").Sheets("DadosProcessados").Activate
     Range("AG" & n).PasteSpecial Paste:=xlValues 'Colagem dos resultados
       Set Horario = Range("AG" & n)
         Horario = Left(Horario, Len(Horario) - 4)

Thanks!

Community
  • 1
  • 1
Felipe
  • 163
  • 3
  • 7
  • 21

1 Answers1

2

Because you are missing a DOT before the range object

Change

With Workbooks(NomeAmostra)
    Range("B55").Copy
End With

to

With Workbooks(NomeAmostra)
    .Range("B55").Copy
End With

Also you might want to see THIS

Community
  • 1
  • 1
Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250