PC Review


Reply
Thread Tools Rate Thread

Adding values to a range

 
 
Jon
Guest
Posts: n/a
 
      20th Nov 2008
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"}


 
Reply With Quote
 
 
 
 
Michael
Guest
Posts: n/a
 
      20th Nov 2008
You must separate each range:

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

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

Michael Arch.




"Jon" wrote:

> 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"}
>
>
>

 
Reply With Quote
 
Jon
Guest
Posts: n/a
 
      20th Nov 2008
Thanks Michael.

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



"Michael" <(E-Mail Removed)> wrote in message
news:877CEFB5-BB33-48C8-8BB0-(E-Mail Removed)...
You must separate each range:

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

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

Michael Arch.




"Jon" wrote:

> 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"}
>
>
>



 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      20th Nov 2008
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.




"Jon" wrote:

> Thanks Michael.
>
> My example was a bit confusing. "A31", "Q12", "J13" is data that goes into cells as values, rather
> than cell numbers.
>
>
>
> "Michael" <(E-Mail Removed)> wrote in message
> news:877CEFB5-BB33-48C8-8BB0-(E-Mail Removed)...
> You must separate each range:
>
> Range("E4").value = Range("A31").value
> Range("E5").value = Range("Q12").value
> Range("E6").value = Range("J13").value
>
> --
> If this posting was helpful, please click on the Yes button.
> Regards,
>
> Michael Arch.
>
>
>
>
> "Jon" wrote:
>
> > 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"}
> >
> >
> >

>
>
>

 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      20th Nov 2008
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

"Michael" wrote:

> 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.
>
>
>
>
> "Jon" wrote:
>
> > Thanks Michael.
> >
> > My example was a bit confusing. "A31", "Q12", "J13" is data that goes into cells as values, rather
> > than cell numbers.
> >
> >
> >
> > "Michael" <(E-Mail Removed)> wrote in message
> > news:877CEFB5-BB33-48C8-8BB0-(E-Mail Removed)...
> > You must separate each range:
> >
> > Range("E4").value = Range("A31").value
> > Range("E5").value = Range("Q12").value
> > Range("E6").value = Range("J13").value
> >
> > --
> > If this posting was helpful, please click on the Yes button.
> > Regards,
> >
> > Michael Arch.
> >
> >
> >
> >
> > "Jon" wrote:
> >
> > > 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"}
> > >
> > >
> > >

> >
> >
> >

 
Reply With Quote
 
Jon
Guest
Posts: n/a
 
      21st Nov 2008
Thanks Michael


"Michael" <(E-Mail Removed)> wrote in message
news:4C2586C2-F40A-4864-9733-(E-Mail Removed)...
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.




"Jon" wrote:

> Thanks Michael.
>
> My example was a bit confusing. "A31", "Q12", "J13" is data that goes into cells as values, rather
> than cell numbers.
>
>
>
> "Michael" <(E-Mail Removed)> wrote in message
> news:877CEFB5-BB33-48C8-8BB0-(E-Mail Removed)...
> You must separate each range:
>
> Range("E4").value = Range("A31").value
> Range("E5").value = Range("Q12").value
> Range("E6").value = Range("J13").value
>
> --
> If this posting was helpful, please click on the Yes button.
> Regards,
>
> Michael Arch.
>
>
>
>
> "Jon" wrote:
>
> > 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"}
> >
> >
> >

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding values if the same - SUMIF in range of cells? Eisaz Microsoft Excel Worksheet Functions 4 18th Nov 2008 05:05 AM
adding range values to array Gary Keramidas Microsoft Excel Programming 2 12th Mar 2007 03:59 AM
Re: adding numbers in a specific range of values Bob Phillips Microsoft Excel Misc 0 27th Dec 2006 04:04 PM
Adding input box number to range of cells values =?Utf-8?B?SmVzc2ljYQ==?= Microsoft Excel Programming 4 22nd Mar 2006 06:02 PM
Adding only Negative values within range Ozzie Microsoft Excel Worksheet Functions 4 13th Feb 2004 11:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:57 AM.