getting value of named range
I have a named range. Lets say it goes over lots of cells.
A1 to E20 Can I get the values out as a string? Single string. I have tried some things like: excel.Workbooks(MyWorkbook).Worksheets(MyWorksheet ).Range(MyRange).value any ideas |
getting value of named range
Is there a particular order that it needs to follow? What do the
cells hold? |
getting value of named range
On Fri, 20 Jun 2008 14:27:48 -0500, "greg" wrote:
I have a named range. Lets say it goes over lots of cells. A1 to E20 Can I get the values out as a string? Single string. I have tried some things like: excel.Workbooks(MyWorkbook).Worksheets(MyWorkshee t).Range(MyRange).value any ideas try this: Function all_values_in_one_string(r As Range) As String Dim s As String For Each c In r s = s & c.Value Next c all_values_in_one_string = s End Function Hope this helps / Lars-Åke |
getting value of named range
On 20 Jun., 21:27, "greg" wrote:
I have a named range. *Lets say it goes over lots of cells. A1 to E20 Can I get the values out as a string? *Single string. I have tried some things like: excel.Workbooks(MyWorkbook).Worksheets(MyWorksheet ).Range(MyRange).value any ideas Hi You need to loop through the cells. Look at this macro, it will loop through the cells row by row. Sub NamedRangeToString() Dim nString As String For Each c In Range("MyRange").Cells nString = nString & c.Value Next MsgBox nString End Sub Regards, Per |
getting value of named range
On Fri, 20 Jun 2008 14:27:48 -0500, "greg" wrote:
I have a named range. Lets say it goes over lots of cells. A1 to E20 Can I get the values out as a string? Single string. I have tried some things like: excel.Workbooks(MyWorkbook).Worksheets(MyWorkshee t).Range(MyRange).value any ideas Not enough data to be sure what you really want, but brute force should work: ===================== Sub foo() Dim c As Range Dim a As String For Each c In Range("MyRange") a = a & c.Value Next c Debug.Print a End Sub ==================== --ron |
getting value of named range
Dim myArray
myArray = Application.Transpose(Range("myRange")) MsgBox myArray(1) -- __________________________________ HTH Bob "greg" wrote in message ... I have a named range. Lets say it goes over lots of cells. A1 to E20 Can I get the values out as a string? Single string. I have tried some things like: excel.Workbooks(MyWorkbook).Worksheets(MyWorksheet ).Range(MyRange).value any ideas |
getting value of named range
thanks all,
I will look into the looping "greg" wrote in message ... I have a named range. Lets say it goes over lots of cells. A1 to E20 Can I get the values out as a string? Single string. I have tried some things like: excel.Workbooks(MyWorkbook).Worksheets(MyWorksheet ).Range(MyRange).value any ideas |
All times are GMT +1. The time now is 02:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com