Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save "Range-Value" to variable?

Hi,

I need to extract the Range of an excel sheet into a variable.
I want to get the "A1:C10" value as a string or as a list, if there
are multiple selections. I have looked into the VBA manual of
WinXP-Excel but I can't found this topic.

VarRange = Worksheet("Sheet1").Range won't work.

If somebody knows an answer, please give me a reply.

sincerely
A. Winter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Save "Range-Value" to variable?

dim MyData as Variant

MyData = Range("A1:C10")

now you have an array (MyData) through which you can
loop..


Sub Test()
Dim MyData As Variant
Dim rw As Long
Dim cl As Long

MyData = Range("A1:C10")

For rw = LBound(MyData, 1) To UBound(MyData, 1)

For cl = LBound(MyData, 2) To UBound(MyData, 2)

' do something with MyData(rw,cl)
MsgBox MyData(rw, cl)
Next cl

Next rw

End Sub



Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hi,

I need to extract the Range of an excel sheet into a

variable.
I want to get the "A1:C10" value as a string or as a

list, if there
are multiple selections. I have looked into the VBA

manual of
WinXP-Excel but I can't found this topic.

VarRange = Worksheet("Sheet1").Range won't work.

If somebody knows an answer, please give me a reply.

sincerely
A. Winter
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Save "Range-Value" to variable?

What do you mean by multiple selections? A1:C10 is multiple cells, but if
selected is a single area. Do you mean multiple areas (non contiguous cells
selected).

--
Regards,
Tom Ogilvy

"Andreas Winter" wrote in message
om...
Hi,

I need to extract the Range of an excel sheet into a variable.
I want to get the "A1:C10" value as a string or as a list, if there
are multiple selections. I have looked into the VBA manual of
WinXP-Excel but I can't found this topic.

VarRange = Worksheet("Sheet1").Range won't work.

If somebody knows an answer, please give me a reply.

sincerely
A. Winter



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Save "Range-Value" to variable?

Andreas,

I may misunderstand your question, but here is my suggestion anyway:

Sub StoreRangeAddresses()
'DEclare variables
Dim i As Long
Dim arr() As String
ReDim arr(1 To Selection.Areas.Count) As String

'Store addresses in array
For i = 1 To Selection.Areas.Count
arr(i) = Selection.Areas(i).Address(False, False)
Next i

'Loop through array and display its contents
For i = 1 To UBound(arr, 1)
MsgBox arr(i)
Next i
End Sub

Ture Magnusson
Karlstad, Sweden

"Andreas Winter" wrote in message
om...
Hi,

I need to extract the Range of an excel sheet into a variable.
I want to get the "A1:C10" value as a string or as a list, if there
are multiple selections. I have looked into the VBA manual of
WinXP-Excel but I can't found this topic.

VarRange = Worksheet("Sheet1").Range won't work.

If somebody knows an answer, please give me a reply.

sincerely
A. Winter



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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
using a "variable" in range names Adam Kroger Excel Discussion (Misc queries) 9 December 11th 05 07:17 PM


All times are GMT +1. The time now is 06:05 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"