View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
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