ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting varible to equal values of a # of cells (https://www.excelbanter.com/excel-programming/358947-setting-varible-equal-values-cells.html)

mozart[_8_]

Setting varible to equal values of a # of cells
 

Is there a way of grabbing the values of a range of cells and assignin
them to a string vairable.

For example if I had RED, BLUE, WHITE in cells A1 to A3 respectively
how could I get my variable strColors=RedBlueWhite

I have tried strColors=Range("A1:A3").value and that obviously did no
work.

Assistance Appreciated

--
mozar
-----------------------------------------------------------------------
mozart's Profile: http://www.excelforum.com/member.php...fo&userid=1331
View this thread: http://www.excelforum.com/showthread.php?threadid=53311


Carim

Setting varible to equal values of a # of cells
 
Hi Mozart,

I hope this will be music to you ...

Sub RWB()
Dim RWB As String
RWB = Range("A1").Value & Range("A2").Value & Range("A3").Value
End Sub

HTH
Cheers
Carim


Carim[_14_]

Setting varible to equal values of a # of cells
 

Hi Mozart,

I hope this will be music to you ...


Sub RWB()
Dim RWB As String
RWB = Range("A1").Value & Range("A2").Value & Range("A3").Value
End Sub


HTH
Cheers
Carim


--
Carim
------------------------------------------------------------------------
Carim's Profile: http://www.excelforum.com/member.php...o&userid=33259
View this thread: http://www.excelforum.com/showthread...hreadid=533112


mozart[_9_]

Setting varible to equal values of a # of cells
 

Yes that would seem the way to do it but it could become painful if say
your range was say 50 cells let alone 62k.

Thanks


--
mozart
------------------------------------------------------------------------
mozart's Profile: http://www.excelforum.com/member.php...o&userid=13314
View this thread: http://www.excelforum.com/showthread...hreadid=533112


Carim

Setting varible to equal values of a # of cells
 
Sub RWB()
Dim RWB As String
Dim i As Integer
For i = 1 To 50
RWB = RWB & Range("A" & i).Value
Next i
End Sub

All the Best
Carim


Dana DeLouis

Setting varible to equal values of a # of cells
 
Would this work for you using the later versions of Excel.
This demo starts at Cell A1 for a size of 50.

Sub Demo()
Dim Str As String
Dim n As Long

n = 50
Str = Join(WorksheetFunction.Transpose(Range("A1").Resiz e(n)),
vbNullString)
End Sub

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"mozart" wrote in
message ...

Yes that would seem the way to do it but it could become painful if say
your range was say 50 cells let alone 62k.

Thanks


--
mozart
------------------------------------------------------------------------
mozart's Profile:
http://www.excelforum.com/member.php...o&userid=13314
View this thread: http://www.excelforum.com/showthread...hreadid=533112




mozart[_10_]

Setting varible to equal values of a # of cells
 

Thanks Dana. That works nicel

--
mozar
-----------------------------------------------------------------------
mozart's Profile: http://www.excelforum.com/member.php...fo&userid=1331
View this thread: http://www.excelforum.com/showthread.php?threadid=53311



All times are GMT +1. The time now is 07:54 AM.

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