Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default getting value of named range

Is there a particular order that it needs to follow? What do the
cells hold?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
If any cell in named range = 8 then shade named range JJ[_8_] Excel Programming 3 August 26th 05 11:09 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"