Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trouble getting used to VBA

I am new to Visual basic and have made only a few
applications i was wondering if someone knew how to name a
range as a variable. The bottom part is where im having
the issue


Thanks

Jeff

Dim INS As Range

ActiveCell.Offset(0, 2).Select
Range(Selection, Selection.End(xlDown)).Select

' Trying to name the following range
INS = activeRange.Select

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Trouble getting used to VBA

If you want to create an Excel name for a range (the same as Define Name):

Range(Selection, Selection.End(xlDown)).Name = "MyName"

If you want to create a range object variable for a range in VB:

Set INS = Range(Selection, Selection.End(xlDown))


--
Jim Rech
Excel MVP
"JF" wrote in message
...
|I am new to Visual basic and have made only a few
| applications i was wondering if someone knew how to name a
| range as a variable. The bottom part is where im having
| the issue
|
|
| Thanks
|
| Jeff
|
| Dim INS As Range
|
| ActiveCell.Offset(0, 2).Select
| Range(Selection, Selection.End(xlDown)).Select
|
| ' Trying to name the following range
| INS = activeRange.Select
|
| End Sub
|
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Trouble getting used to VBA

JF wrote:

I am new to Visual basic and have made only a few
applications i was wondering if someone knew how to name a
range as a variable. The bottom part is where im having
the issue


Thanks

Jeff

Dim INS As Range

ActiveCell.Offset(0, 2).Select
Range(Selection, Selection.End(xlDown)).Select

' Trying to name the following range
INS = activeRange.Select

End Sub



The following macro (Sub procedure) will assign the designated
range to the variable "INS":

Sub BBB()
Dim rngTemp As Range, INS As Range
Set rngTemp = ActiveCell(1, 3) '<---This is equivalent to
'Set rngTemp = ActiveCell.Offset(0, 2)
Set INS = Range(rngTemp, rngTemp.End(xlDown))
End Sub
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
Trouble. Mark Charts and Charting in Excel 1 March 1st 09 04:20 AM
Still having trouble scott Excel Discussion (Misc queries) 3 May 17th 06 08:01 PM
>= Trouble AcesUp Excel Discussion (Misc queries) 3 August 23rd 05 11:43 PM
still having trouble with this.... nick Excel Worksheet Functions 4 March 13th 05 07:40 PM
trouble with add ins caia Excel Discussion (Misc queries) 1 February 16th 05 01:17 AM


All times are GMT +1. The time now is 08:47 PM.

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"