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

New to Excel VBA. The following does not return the current active cell
but returns error 91.

Sub Macro1()
'
' Macro1 Macro
'
Dim rangeCurrentCell As Range
'
rangeCurrentCell = ActiveCell

'more stuff

The defn. of ActiveCell is confusing me. All I want is the currently
selected in A1 type format.

Thanks.

Thomas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Find active cell

Thomas, It lloks as if you are lloking for : ActiveCell.Address
This will return $H$7 if the cursor is on cell H7.

--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *

"Thomas" wrote in message
...
New to Excel VBA. The following does not return the current active cell
but returns error 91.

Sub Macro1()
'
' Macro1 Macro
'
Dim rangeCurrentCell As Range
'
rangeCurrentCell = ActiveCell

'more stuff

The defn. of ActiveCell is confusing me. All I want is the currently
selected in A1 type format.

Thanks.

Thomas



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Find active cell

Thomas,

Object variables are assigned with the Set command

Set rangeCurrentCell = ActiveCell

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Thomas" wrote in message
...
New to Excel VBA. The following does not return the current active cell
but returns error 91.

Sub Macro1()
'
' Macro1 Macro
'
Dim rangeCurrentCell As Range
'
rangeCurrentCell = ActiveCell

'more stuff

The defn. of ActiveCell is confusing me. All I want is the currently
selected in A1 type format.

Thanks.

Thomas



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Find active cell

Perhaps I am being dense (wouldn't be the first time). However, this
code still gives the same error (Run time error '91': Object variable or
With block variable not set)

Sub Macro1()
'
' Macro1 Macro
'
Dim rangeCurrentCell As Range
'
rangeCurrentCell = ActiveCell.Address

' more stuff…

If fails at the rangeCurrentCell = ActiveCell.Address line.

The other solution, "Set rangeCurrentCell = ActiveCell" fails the same way.

What am I missing? This should not be that hard.

Thanks.

Best regards,

Thomas



Bob Phillips wrote:
Thomas,

Object variables are assigned with the Set command

Set rangeCurrentCell = ActiveCell

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Find active cell

Thomas,

You are mixing types up.

You declare rangeCurrentCell as a range, but then try to use it as a
variable and assign it a string value. This works

Dim rangeCurrentCell As String
'
rangeCurrentCell = ActiveCell.Address

I am also surprised to hear you say that

Set rangeCurrentCell = ActiveCell

it certainly works for me as long as rangeCurrentCell is declared as range
or variant.
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Thomas" wrote in message
...
Perhaps I am being dense (wouldn't be the first time). However, this
code still gives the same error (Run time error '91': Object variable or
With block variable not set)

Sub Macro1()
'
' Macro1 Macro
'
Dim rangeCurrentCell As Range
'
rangeCurrentCell = ActiveCell.Address

' more stuff…

If fails at the rangeCurrentCell = ActiveCell.Address line.

The other solution, "Set rangeCurrentCell = ActiveCell" fails the same

way.

What am I missing? This should not be that hard.

Thanks.

Best regards,

Thomas



Bob Phillips wrote:
Thomas,

Object variables are assigned with the Set command

Set rangeCurrentCell = ActiveCell





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Find active cell

Oi! Thanks, Bob. Got off on the wrong track and couldn't see it. Not
sure about the rangeCurrentCell = ActiveCell. I will look further into it.

Thomas

Bob Phillips wrote:

Thomas,

You are mixing types up.

You declare rangeCurrentCell as a range, but then try to use it as a
variable and assign it a string value. This works

Dim rangeCurrentCell As String
'
rangeCurrentCell = ActiveCell.Address

I am also surprised to hear you say that

Set rangeCurrentCell = ActiveCell

it certainly works for me as long as rangeCurrentCell is declared as range
or variant.

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
macro to find cell content in sheets and make sheet active Nigel Excel Discussion (Misc queries) 4 June 26th 14 02:38 PM
Row select mode to highlight active row of active cell Bart Fay[_2_] Excel Discussion (Misc queries) 0 May 11th 10 09:34 PM
Find last cell in a column, Delete its contents and make it active George Excel Worksheet Functions 5 January 28th 10 05:38 PM
Find address of active cell Dave Excel Worksheet Functions 5 September 6th 06 06:43 PM
copy active cell value,find the pasted value in different worksheet [email protected] Excel Worksheet Functions 2 July 9th 06 09:56 AM


All times are GMT +1. The time now is 12:47 AM.

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"