Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Select next object

I want to write code to select the next object (like hitting Tab) and select
the last object (like Shift-Tab). But when I record this macro, it specifies
code for selecting the actual object name. Even if I click the relative box.
How can I do this so that I don't have to specify the name of the object, so
it will work on any set of objects?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Select next object

Objects aren't relative to each other.

I guess you could do

Dim bMe as Boolean, shp as Shape
Dim oshp as Shape, bGoForward as Boolean
for each shp in Activesheet.shapes
if shp.name = selection.Name then
if not bGoForward then
oshp.select
exit for
end if
bme = true
end if
if bGoForward then
if bme and not shp.Name < selection.Name then
bme = False
shp.Select
exit for
end if
end if
set oshp = shp
Next

but I believe this collection is in the order the shapes were added.

--
Regards,
Tom Ogilvy


"Mike" wrote:

I want to write code to select the next object (like hitting Tab) and select
the last object (like Shift-Tab). But when I record this macro, it specifies
code for selecting the actual object name. Even if I click the relative box.
How can I do this so that I don't have to specify the name of the object, so
it will work on any set of objects?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Select next object

See, basically what I have is a map with several objects inside it. Each
state is an object. At times, the user will have every object selected so
that it can be copied. I then want to be able to have the user select another
macro, either if all objects are still selected, or if only one object is
selected. Each Map on the sheet has a different number, which is part of
every object in that map, say 35. So I want to be able to pull that map
number out so that the next macro can be ran. If the user has one object
selected in the map prior to running the macro, no problem. I can pull the
number out of the object name. BUT, if they have all objects selected on the
map, I can't pull out the number. So I could figure out the code to select
only one object from the selected objects. This probably isn't making any
sense. Sorry.

"Tom Ogilvy" wrote:

Objects aren't relative to each other.

I guess you could do

Dim bMe as Boolean, shp as Shape
Dim oshp as Shape, bGoForward as Boolean
for each shp in Activesheet.shapes
if shp.name = selection.Name then
if not bGoForward then
oshp.select
exit for
end if
bme = true
end if
if bGoForward then
if bme and not shp.Name < selection.Name then
bme = False
shp.Select
exit for
end if
end if
set oshp = shp
Next

but I believe this collection is in the order the shapes were added.

--
Regards,
Tom Ogilvy


"Mike" wrote:

I want to write code to select the next object (like hitting Tab) and select
the last object (like Shift-Tab). But when I record this macro, it specifies
code for selecting the actual object name. Even if I click the relative box.
How can I do this so that I don't have to specify the name of the object, so
it will work on any set of objects?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Select next object

Possibly something like this to loop through all the selected states.

dim o as Object
for each o in selection
msgbox o.name
Next

--
Regards,
Tom Ogilvy


"Mike" wrote:

See, basically what I have is a map with several objects inside it. Each
state is an object. At times, the user will have every object selected so
that it can be copied. I then want to be able to have the user select another
macro, either if all objects are still selected, or if only one object is
selected. Each Map on the sheet has a different number, which is part of
every object in that map, say 35. So I want to be able to pull that map
number out so that the next macro can be ran. If the user has one object
selected in the map prior to running the macro, no problem. I can pull the
number out of the object name. BUT, if they have all objects selected on the
map, I can't pull out the number. So I could figure out the code to select
only one object from the selected objects. This probably isn't making any
sense. Sorry.

"Tom Ogilvy" wrote:

Objects aren't relative to each other.

I guess you could do

Dim bMe as Boolean, shp as Shape
Dim oshp as Shape, bGoForward as Boolean
for each shp in Activesheet.shapes
if shp.name = selection.Name then
if not bGoForward then
oshp.select
exit for
end if
bme = true
end if
if bGoForward then
if bme and not shp.Name < selection.Name then
bme = False
shp.Select
exit for
end if
end if
set oshp = shp
Next

but I believe this collection is in the order the shapes were added.

--
Regards,
Tom Ogilvy


"Mike" wrote:

I want to write code to select the next object (like hitting Tab) and select
the last object (like Shift-Tab). But when I record this macro, it specifies
code for selecting the actual object name. Even if I click the relative box.
How can I do this so that I don't have to specify the name of the object, so
it will work on any set of objects?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Select next object

Hey, thanks. Using a variation of this, I was able to select just the object
I need to determine the map number. Thanks!

"Mike" wrote:

I want to write code to select the next object (like hitting Tab) and select
the last object (like Shift-Tab). But when I record this macro, it specifies
code for selecting the actual object name. Even if I click the relative box.
How can I do this so that I don't have to specify the name of the object, so
it will work on any set of objects?

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
Creating resizing macro - select chart as object? ellinoz Charts and Charting in Excel 3 April 4th 08 09:33 AM
automatically select object references Job Excel Programming 0 February 3rd 05 09:41 PM
Highlight/Select contents of object with focus andy[_5_] Excel Programming 2 January 15th 04 02:44 PM
how to select two separate ranges into range object Serge[_2_] Excel Programming 2 October 1st 03 03:10 PM
Cannot select object to assign/edit macro Iain Paine Excel Programming 2 August 13th 03 03:02 PM


All times are GMT +1. The time now is 12:28 PM.

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"