PC Review


Reply
Thread Tools Rate Thread

How do I display cell name with Msgbox?

 
 
nomail1983@hotmail.com
Guest
Posts: n/a
 
      17th Sep 2007
As I said before, I left my VBA programming book at home. So I'm
flying blind. Sorry for the rudimentary questions.

How do I display the cell name with Msgbox?

For example (pseudocode):

function myfunc(arg)
if TypeName(arg) = "Range" then
for each cell in arg
Msgbox cell.Name
next
end if
end function

 
Reply With Quote
 
 
 
 
I.R;))
Guest
Posts: n/a
 
      17th Sep 2007
On 17 ruj, 10:58, "nomail1...@hotmail.com" <nomail1...@hotmail.com>
wrote:
> As I said before, I left my VBA programming book at home. So I'm
> flying blind. Sorry for the rudimentary questions.
>
> How do I display the cell name with Msgbox?
>
> For example (pseudocode):
>
> function myfunc(arg)
> if TypeName(arg) = "Range" then
> for each cell in arg
> Msgbox cell.Name
> next
> end if
> end function


In VBA editor you must DBLClick on sheet (no module), for example
"Sheet1" and paste this source

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox (Target.Address)
End Sub




 
Reply With Quote
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      17th Sep 2007
Hi,

Sub ListNamedRanges()
Dim objName As Name
For Each objName In ThisWorkbook.Names
MsgBox objName.Name & objName.RefersTo
Next
End Sub

Mike

"(E-Mail Removed)" wrote:

> As I said before, I left my VBA programming book at home. So I'm
> flying blind. Sorry for the rudimentary questions.
>
> How do I display the cell name with Msgbox?
>
> For example (pseudocode):
>
> function myfunc(arg)
> if TypeName(arg) = "Range" then
> for each cell in arg
> Msgbox cell.Name
> next
> end if
> end function
>
>

 
Reply With Quote
 
nomail1983@hotmail.com
Guest
Posts: n/a
 
      17th Sep 2007
On Sep 17, 2:16 am, "I.R)" <iraml...@ramtech.hr> wrote:
> On 17 ruj, 10:58, <nomail1...@hotmail.com> wrote:
> > How do I display the cell name with Msgbox?

> [....]
> MsgBox (Target.Address)


Perfect! Thanks.

 
Reply With Quote
 
I.R;))
Guest
Posts: n/a
 
      17th Sep 2007
On 17 ruj, 12:05, "nomail1...@hotmail.com" <nomail1...@hotmail.com>
wrote:
> On Sep 17, 2:16 am, "I.R)" <iraml...@ramtech.hr> wrote:
>
> > On 17 ruj, 10:58, <nomail1...@hotmail.com> wrote:
> > > How do I display the cell name with Msgbox?

> > [....]
> > MsgBox (Target.Address)

>
> Perfect! Thanks.


No problemo!!!!

 
Reply With Quote
 
Bill Renaud
Guest
Posts: n/a
 
      18th Sep 2007
Looks like it's about time to start learn to use the Object Browser, and
the Locals and Immediate windows in the VBA editor. (Most of my VBA
books stay on the shelf anymore also.)

Since you know that you are probably looking for a property or something
that is related to a Range, open up the Object Browser (<F2> key), then
type Range into the "Search Text" combo box. You could also choose
"Excel" in the "Project/Library" combo box right above it to limit the
search. Search Results will show a table with the first column being
"Library", the next being Class, and the last being Member. Click on the
row that has Excel in the Library column and Range in the Class column.
2 list boxes below the "Search Results" will show Classes and Members of
'Range'. Select "Range" in the Classes list box, then scroll up and down
the list of Members in the list box to the right. Notice that "Address"
is one of the Members. Click on it and see the arguments, return type,
and read/write status in the gray area at the bottom.

Alternatively, type in a quick demo routine, like below:

Public Sub Test()
Dim rng As Range

Set rng = ActiveCell
End Sub

Single-step through the routine, until reaching the End Sub line. In the
locals window, open up the "rng" object and see if you can find any
properties that look like they might give you what you want.

Also, open up the Immediate window, and type in the following (after you
type the period, auto-data members should bring up a drop down box so
the "Address" can be selected without having to type it all (be sure to
include the "?" at the front end):

?rng.Address

After pressing Enter, the VBA run-time will return the current result:

$A$1

Maybe this is what you are looking for? Try different properties (edit
the original line) until you see something interesting, then use Help to
get the usage details.

Sorry if this reply is sounds condescending, but we all (including
me!!!) need to get better at looking up stuff using all of the online
resources! I realize Microsoft didn't explain the VBA environment very
well or how to use the editor features to the fullest extent. It took me
quite a while to learn them also!!!
--
Regards,
Bill Renaud


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
find last non empty cell in a column and display value in msgbox vbnewbie Microsoft Excel Programming 7 4th Feb 2009 10:08 AM
MsgBox - Display variable in MsgBox Shiller Microsoft Access VBA Modules 2 29th Sep 2008 10:14 PM
msgbox to display a cell value, HOW, If possible? Corey Microsoft Excel Programming 2 3rd Nov 2006 05:23 AM
How to display remaining txt file which overflowed MsgBox display? EagleOne Microsoft Excel Misc 1 2nd Nov 2006 01:10 PM
display cell value in msgbox formatted as % rgarber50 Microsoft Excel Misc 5 10th Jul 2005 03:27 PM


Features
 

Advertising
 

Newsgroups
 


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