Adding values to a range

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

Is there a shorthand way to do add a set of different values to a range, as shown in this incorrect
code, which would set E4 to "A31", E5 to "Q12" and E6 to "J13"?

Worksheets("Sheet1").Range("E4:E6").Value = {"A31", "Q12", "J13"}
 
You must separate each range:

Range("E4").value = Range("A31").value
Range("E5").value = Range("Q12").value
Range("E6").value = Range("J13").value
 
Thanks Michael.

My example was a bit confusing. "A31", "Q12", "J13" is data that goes into cells as values, rather
than cell numbers.



You must separate each range:

Range("E4").value = Range("A31").value
Range("E5").value = Range("Q12").value
Range("E6").value = Range("J13").value
 
Try this:
Range("E4").value = "A31"
Range("E5").value = "Q12"
Range("E6").value = "J13"

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.
 
Sub setValues()
Dim myValues(2) As Variant
Dim v As Variant

myValues(0) = "A31"
myValues(1) = "Q12"
myValues(2) = "J13"

i = 4
For Each v In myValues
Range("E" & i).Value = v
i = i + 1
Next
End Sub
 
Thanks Michael


Try this:
Range("E4").value = "A31"
Range("E5").value = "Q12"
Range("E6").value = "J13"

--
If this posting was helpful, please click on the Yes button.
Regards,

Michael Arch.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top