Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Range as Variable

hi,
after looking at what your code is trying to do, i am guessing that you are
trying to set the font size in the selected range.
try this....
Sub test1()
Dim x As Range 'not needed
Set x = Selection 'not needed
MsgBox x.Address 'not needed
dim fs as long
Application.Dialogs(xlDialogActiveCellFont).Show Arg3:=0
fs = ActiveCell.Font.Size
With Selection.Font
.Size = fs
End With
End Sub

regards
FSt1

"FSt1" wrote:

hi
the code i supplied does assign the select range to x. which is what you
asked for.
your are getting an application define error on this line
Selection.AutoFill Destination:=ActiveCell.Range(x), Type:=xlFillDefault

what are you trying to do?

regards
FSt1

"lwm" wrote:

When I do this

Set x = Selection

Application.Dialogs(xlDialogActiveCellFont).Show Arg3:=0
'
Selection.AutoFill Destination:=ActiveCell.Range(x), Type:=xlFillDefault

this fails

if I do x = "a1:L1" it works.

I am trying to have the ability to use whatever range the user has already
selected. If I hard code it then I can't allow changes.


"FSt1" wrote:

hi
it worked in 2003. I retested to make sure. here is the copy and paste from
my vb editor..
Sub test1()
Dim x As Range
Set x = Selection
MsgBox x.Address
End Sub
x is the variable. make sure you pre-select the range before running the
macro.

regards
FSt1

"lwm" wrote:

Set x = selection does not seem to work. I want a currently selected area
that I will not know in advance. So it must take the currently selected area
and save that to a variable.

x = what ever the current selction is.

"FSt1" wrote:

or..
you can highlight a range....
dim x as range
set x = selection
msgbox x.address

regards
FSt1

"FSt1" wrote:

hi
current range?????
dim x as range
set x = range("A1:L100")'set to current range

regards
FSt1



"lwm" wrote:

I want to take the current range and assign it to a variable touse in
additional functions.

How do I assign the current range to a variable like X?

Thanks

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
Range to VLOOKUP as a Variable (range in another file) LuisE Excel Programming 3 December 2nd 07 03:22 PM
select range and put range address in variable [email protected] Excel Programming 2 January 25th 06 01:28 AM
Macro to copy a specified range to a variable range SWT Excel Programming 4 October 21st 05 08:24 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Problem trying to us a range variable as an array variable TBA[_2_] Excel Programming 4 September 27th 03 02:56 PM


All times are GMT +1. The time now is 06:10 AM.

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

About Us

"It's about Microsoft Excel"