Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Set variable to active cell address

I just need to set the value of a variable to the "A1" address of the
active cell. I feel like I've tried everything, but shouldn't this
work....

Dim rng as Range

Set rng = activecell [results in active cell's
value]
Set rng = activecell.address [throws error]

Thanks all,
Shelton.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Set variable to active cell address

Hi,


Dim rngAddr As String
Dim rng As Range

Set rng = ActiveCell

rngAddr = rng.Address 'returns $A$1
rngAddr = rng.Address(0, 0) 'returns A1
rngAddr = rng.Address(0, 1) 'returns $A1
rngAddr = rng.Address(1, 0) 'returns A$1

'Use address like this

Range (rngAddr)

--
Regards,

OssieMac


"shelfish" wrote:

I just need to set the value of a variable to the "A1" address of the
active cell. I feel like I've tried everything, but shouldn't this
work....

Dim rng as Range

Set rng = activecell [results in active cell's
value]
Set rng = activecell.address [throws error]

Thanks all,
Shelton.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Set variable to active cell address

On Nov 20, 9:07 pm, OssieMac
wrote:
Hi,

Dim rngAddr As String
Dim rng As Range

Set rng = ActiveCell

rngAddr = rng.Address 'returns $A$1
rngAddr = rng.Address(0, 0) 'returns A1
rngAddr = rng.Address(0, 1) 'returns $A1
rngAddr = rng.Address(1, 0) 'returns A$1

'Use address like this

Range (rngAddr)

--
Regards,

OssieMac

"shelfish" wrote:
I just need to set the value of a variable to the "A1" address of the
active cell. I feel like I've tried everything, but shouldn't this
work....


Dim rng as Range


Set rng = activecell [results in active cell's
value]
Set rng = activecell.address [throws error]


Thanks all,
Shelton.


Brilliant! Thanks for the help.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Set variable to active cell address

rng = ActiveCell gives value
rng = ActiveCell.Address gives cell reference in A1 format
Set rng = ActiveCell is used to set the active cell as an object variable
range
then you cans do: x = rng.address to get a cell string in A1 format.

I get screwed around on these also. The best way to do it is to use a Range
or Cells reference if you can. If you have to have a variable, then don't
forget that it is a cell reference and you will need to use it like
Range(rng) when setting a range reference.

"shelfish" wrote:

I just need to set the value of a variable to the "A1" address of the
active cell. I feel like I've tried everything, but shouldn't this
work....

Dim rng as Range

Set rng = activecell [results in active cell's
value]
Set rng = activecell.address [throws error]

Thanks all,
Shelton.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Set variable to active cell address

dim myAddr as string
myAddr = activecell.address(0,0)



shelfish wrote:

I just need to set the value of a variable to the "A1" address of the
active cell. I feel like I've tried everything, but shouldn't this
work....

Dim rng as Range

Set rng = activecell [results in active cell's
value]
Set rng = activecell.address [throws error]

Thanks all,
Shelton.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Set variable to active cell address

Very nice that you did this in one step. I knew it couldn't be a two-
step process. 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
How can I use the active cell address as a value mohavv Excel Discussion (Misc queries) 2 April 18th 08 06:16 AM
Get Address of Active Cell LarryL Excel Discussion (Misc queries) 3 February 16th 07 10:02 PM
Find address of active cell Dave Excel Worksheet Functions 5 September 6th 06 06:43 PM
Getting active cell address bmwmcrider Excel Programming 5 October 8th 03 03:23 PM
How to get the active cell address? d Excel Programming 1 August 25th 03 04:34 PM


All times are GMT +1. The time now is 04:23 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"