ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I create a string from a range (Excel VBA)? (https://www.excelbanter.com/excel-programming/401017-how-do-i-create-string-range-excel-vba.html)

JJ

How do I create a string from a range (Excel VBA)?
 
I want to create a userform that can string a selected range of cells to a
textbox. I can do it on predifend cells, but I want it to be flexible so
that you can highlight the cells and then click a button that will string it.
Can anybody help me with a link to a page that explain how to string from
highlighted cells?

Bob Phillips

How do I create a string from a range (Excel VBA)?
 
Dim rng As Range
Dim cell As Range
Dim str

Set rng = Application.InputBox("Use mo=use to select cells", Type:=8)
For Each cell In rng
str = str & cell.Value & " "
Next cell
TextBox1.Text = str


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"JJ" wrote in message
...
I want to create a userform that can string a selected range of cells to a
textbox. I can do it on predifend cells, but I want it to be flexible so
that you can highlight the cells and then click a button that will string
it.
Can anybody help me with a link to a page that explain how to string from
highlighted cells?





All times are GMT +1. The time now is 11:28 AM.

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