A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Newbee show cell address



 
 
Thread Tools Display Modes
  #1  
Old September 16th, 2003, 04:30 PM
Microsoft Newsgroups
external usenet poster
 
Posts: n/a
Default Newbee show cell address

I am having difficulty tranfering from C to VB.

How can I assign, pss, or MsgBox the string address of a particular cell.

If I use

Dim cellref as Object
cellref = activecell

Then cellref is neither the address nor the value of that cell, since
cellref is of type Object. Is this true?

I am learning. Bear with me. Please

John


  #2  
Old September 16th, 2003, 04:47 PM
J.E. McGimpsey
external usenet poster
 
Posts: n/a
Default Newbee show cell address

No, you'll get a syntax error. You need to use Set to assign an
object variable:

Set cellref = ActiveCell

You can use prebinding and assign cellref to a Range object as

Dim cellref As Range

If you want the value instead (say as a Double):

Dim cellRef As Double
cellref = ActiveCell.Value

(or cellref = ActiveCell, since the Value property is the default
property for a range)

If you want the address:

Dim cellRef As String
cellref = ActiveCell.Address

In article ,
"Microsoft Newsgroups" wrote:

I am having difficulty tranfering from C to VB.

How can I assign, pss, or MsgBox the string address of a particular cell.

If I use

Dim cellref as Object
cellref = activecell

Then cellref is neither the address nor the value of that cell, since
cellref is of type Object. Is this true?

I am learning. Bear with me. Please

John


  #3  
Old September 16th, 2003, 04:57 PM
Harald Staff
external usenet poster
 
Posts: n/a
Default Newbee show cell address

Hi John

Right. Object, like Variant, is anything and everything. Range is a collection of one or
more cells. String is good old string. So choose your weapon depending on what you want
done and how much stack space you want it to use. Note also that objects and ranges needs
Set to assign things, other datatypes not. As in

Sub TwoWays()
Dim cellref As Range
Dim Celladr As String

Set cellref = ActiveCell
MsgBox cellref.Address & Chr(10) & cellref.Value& chr(10) & cellref.Formula 'and so on...

Celladr = ActiveCell.Address
MsgBox Celladr
End Sub

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"Microsoft Newsgroups" wrote in message
...
I am having difficulty tranfering from C to VB.

How can I assign, pss, or MsgBox the string address of a particular cell.

If I use

Dim cellref as Object
cellref = activecell

Then cellref is neither the address nor the value of that cell, since
cellref is of type Object. Is this true?

I am learning. Bear with me. Please

John




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:24 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.