ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Multiple Ranges = same value (https://www.excelbanter.com/excel-discussion-misc-queries/212343-multiple-ranges-%3D-same-value.html)

jlclyde

Multiple Ranges = same value
 
I have 3 ranges, that I want to = the same number. I am doing this
with VBA. Is there an easier way then
Range("A3") = 5
Range("A9") = 5
Range"E42")=5
??
Thanks,
Jay

Gary''s Student

Multiple Ranges = same value
 
Sub servient()
Range("A3,A9,E42").Value = 5
End Sub

another way is to use Union()

I think that with regard to speed, it does not matter.
--
Gary''s Student - gsnu2007k


"jlclyde" wrote:

I have 3 ranges, that I want to = the same number. I am doing this
with VBA. Is there an easier way then
Range("A3") = 5
Range("A9") = 5
Range"E42")=5
??
Thanks,
Jay


Dave Peterson

Multiple Ranges = same value
 
Except for the typo <vbg, that looks the easiest to me.

But you could use:
ActiveSheet.Range("a3,a9,e42").Value = 5

This worked in xl2003.

jlclyde wrote:

I have 3 ranges, that I want to = the same number. I am doing this
with VBA. Is there an easier way then
Range("A3") = 5
Range("A9") = 5
Range"E42")=5
??
Thanks,
Jay


--

Dave Peterson

jlclyde

Multiple Ranges = same value
 
On Dec 3, 10:29*am, Gary''s Student
wrote:
Sub servient()
Range("A3,A9,E42").Value = 5
End Sub

another way is to use Union()

I think that with regard to speed, it does not matter.
--
Gary''s Student - gsnu2007k



"jlclyde" wrote:
I have 3 ranges, that I want to = the same number. *I am doing this
with VBA. *Is there an easier way then
Range("A3") = 5
Range("A9") = 5
Range"E42")=5
??
Thanks,
Jay- Hide quoted text -


- Show quoted text -


Thanks. I was trying Range("A3", "A9", "E42"). this will be much
easier!
Jay


All times are GMT +1. The time now is 06:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com