ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ActiveCell (https://www.excelbanter.com/excel-programming/369844-activecell.html)

[email protected]

ActiveCell
 
Get a funny problem which was working.

Have the following. I enter 3453 in C15.

in VB have the following

Dim InputRange as Range
Set InputRange = Activecell

This should return C15 (or the active cell address). Instead it keeps
returning 3453.

This was working previously - any ideas - only thing I can think of is
the Excel is 2003-SR1

Desperate to get this working

Thanks


Harald Staff

ActiveCell
 
Your provided code does not return anything, it sets a range, which works,
as in:


Sub Test()
Dim InputRange As Range
Set InputRange = ActiveCell
Range("C14").Select
MsgBox "Will return from C14 to InputRange now."
InputRange.Select
End Sub

What I suspect that you do is not defining which property to use, like

MsgBox InputRange

That lazy coding is only acceptable if you know the object model extremely
well and don't share co de with others. You expect the Address property in
return, but what you get is the Value property if you leave it out:

MsgBox InputRange.Address
MsgBox InputRange.Value
MsgBox InputRange.Font.Name

HTH. Best wishes Harald

skrev i melding
oups.com...
Get a funny problem which was working.

Have the following. I enter 3453 in C15.

in VB have the following

Dim InputRange as Range
Set InputRange = Activecell

This should return C15 (or the active cell address). Instead it keeps
returning 3453.

This was working previously - any ideas - only thing I can think of is
the Excel is 2003-SR1

Desperate to get this working

Thanks




Gary''s Student

ActiveCell
 
It is defaulting to the Value.

InputRange.Value should give 3453
and
InputRange.Address should give C15
--
Gary's Student


" wrote:

Get a funny problem which was working.

Have the following. I enter 3453 in C15.

in VB have the following

Dim InputRange as Range
Set InputRange = Activecell

This should return C15 (or the active cell address). Instead it keeps
returning 3453.

This was working previously - any ideas - only thing I can think of is
the Excel is 2003-SR1

Desperate to get this working

Thanks




All times are GMT +1. The time now is 07:03 AM.

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