![]() |
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 |
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 | | |
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 |
All times are GMT +1. The time now is 01:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com