ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Public variable declaration (https://www.excelbanter.com/excel-programming/433829-public-variable-declaration.html)

Alberto Ast[_2_]

Public variable declaration
 
I tried first searching on the discussion group already place questions but
could not find what I need.

I have a variable I use to store a cell address

xlast = ActiveCell.Address

I am trying to declare it as public so I can use it in other modules but I
have fail several ways... what I have is

Global xlast As Range

Is the Range type correct? or how should I do?

JLGWhiz[_2_]

Public variable declaration
 
ActiveCell.Address is a string.
So:
Public xlast As String

If you used:
Set xlast = ActiveCell
Then
Public xlast As Range would be correct
"Alberto Ast" wrote in message
...
I tried first searching on the discussion group already place questions but
could not find what I need.

I have a variable I use to store a cell address

xlast = ActiveCell.Address

I am trying to declare it as public so I can use it in other modules but I
have fail several ways... what I have is

Global xlast As Range

Is the Range type correct? or how should I do?




Alberto Ast[_2_]

Public variable declaration
 
Thanks it works...

Have another question related for future reference...

If I use string then I can use
xlast = activecell.address
range ("A1",xlast).select

but if I use range
I need to do
set xlast = Activecell

How do I get into this cell in the future?
range("A1",xlaset).select will not work
"JLGWhiz" wrote:

ActiveCell.Address is a string.
So:
Public xlast As String

If you used:
Set xlast = ActiveCell
Then
Public xlast As Range would be correct
"Alberto Ast" wrote in message
...
I tried first searching on the discussion group already place questions but
could not find what I need.

I have a variable I use to store a cell address

xlast = ActiveCell.Address

I am trying to declare it as public so I can use it in other modules but I
have fail several ways... what I have is

Global xlast As Range

Is the Range type correct? or how should I do?





Per Jessen[_2_]

Public variable declaration
 
Hi

DIm xLast as string
xlast = activecell.address
range ("A1",Range(xlast)).select

Or

Dim xLast as Range
set xlast =activecell
range("A1", xlast).seleect


Regards,
Per

On 19 Sep., 03:54, Alberto Ast
wrote:
Thanks it works...

Have another question related for future reference...

If I use string then I can use
xlast = activecell.address
range ("A1",xlast).select

but if I use range
I need to do
set xlast = Activecell

How do I get into this cell in the future?
range("A1",xlaset).select will not work



"JLGWhiz" wrote:
ActiveCell.Address is a string.
So:
Public xlast As String


If you used:
Set xlast = ActiveCell
Then
Public xlast As Range would be correct
"Alberto Ast" wrote in message
...
I tried first searching on the discussion group already place questions but
could not find what I need.


I have a variable I use to store a cell address


* *xlast = ActiveCell.Address


I am trying to declare it as public so I can use it in other modules but I
have fail several ways... what I have is


* *Global xlast As Range


Is the Range type correct? or how should I do?- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -



Rick Rothstein

Public variable declaration
 
DIm xLast as string
xlast = activecell.address
range ("A1",Range(xlast)).select

Or

Dim xLast as Range
set xlast =activecell
range("A1", xlast).select


You can use same last line...

Range("A1", xlast).Select

for both of these approaches.

--
Rick (MVP - Excel)


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com