Public variable declaration

A

Alberto Ast

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?
 
J

JLGWhiz

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

If you used:
Set xlast = ActiveCell
Then
Public xlast As Range would be correct
 
A

Alberto Ast

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
 
P

Per Jessen

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
 
R

Rick Rothstein

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top