1

I am trying to copy cell values from the same worksheet. It would only paste one value out of the three.

Sheets("Median_make").Select
    Range("B3").Copy
    Range("H4").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Median_make").Select
    Range("E3").Copy
    Range("K4").PasteSpecial xlPasteValues
Sheets("Median_make").Select
    Range("D3").Copy
    Sheets("Median_make").Range("J4").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Community
  • 1
  • 1
Ann P
  • 11
  • 2
  • 1
    `Sheets("Median_make").Range("H4").Value = Sheets("Median_make").Range("B3").Value`. Assign the value directly, no need to use copy/paste. – Raymond Wu Mar 04 '22 at 08:00
  • You also do not need to use `Select` most of the time. I recommend you to read up on [how to avoid using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba?rq=1) – Raymond Wu Mar 04 '22 at 08:31

1 Answers1

0

The following code would perform your requirement and would not require you to have the sheet selected at all:

With Sheets("Median_make")
    .Range("H4").Value = .Range("B3").Value
    .Range("K4").Value = .Range("E3").Value
    .Range("J4").Value = .Range("D3").Value
End With
CLR
  • 11,284
  • 1
  • 11
  • 29