Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Snap Object to cell borders


I'm writing an application where users will move around several
objects (Label fields) on a worksheet

1. How can I make the objects "snap" to the cell borders ?
2. Is it possible to "link" two or more objets (on different worksheets)
so that all "linked" objects are moved simultaneously if one of them
is moved?

Thanks a lot for any ideas or suggestions !

Ed

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Snap Object to cell borders

"Snapping" is accomplished by adjusting an object's Top and Left properties
to those of the underlying cell:

Dim x As Shape
Set x = Sheet1.Shapes(1)
x.Left = x.TopLeftCell.Left
'etc

No way to link the moving of objects. You'd have to write a macro to do
that.

--
Jim
"Ed Schwartz" wrote in message
...
|
| I'm writing an application where users will move around several
| objects (Label fields) on a worksheet
|
| 1. How can I make the objects "snap" to the cell borders ?
| 2. Is it possible to "link" two or more objets (on different worksheets)
| so that all "linked" objects are moved simultaneously if one of them
| is moved?
|
| Thanks a lot for any ideas or suggestions !
|
| Ed
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Snap Object to cell borders


Thanks a lot, Jim - works very well !



Dim x As Shape
Set x = Sheet1.Shapes(1)
x.Left = x.TopLeftCell.Left
'etc

No way to link the moving of objects. You'd have to write a macro to do
that.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Snap Object to cell borders


1. How can I make the objects "snap" to the cell borders ?

On Excel's Drawing toolbar, click Draw Snap To Grid.



2. Is it possible to "link" two or more objets (on different worksheets)
so that all "linked" objects are moved simultaneously if one of them
is moved?

If the shapes on sheet1 and sheet2 were given the same names on both sheets,
you could use the following code to update their positions.

'In Sheet1's code module
Private Sub Worksheet_Activate()
Dim shp As Shape
For Each shp In Sheets("Sheet1").Shapes
shp.Top = Sheets("Sheet2").Shapes(shp.Name).Top
shp.Left = Sheets("Sheet2").Shapes(shp.Name).Left
Next
End Sub

'In sheet2's code module
Private Sub Worksheet_Activate()
Dim shp As Shape
For Each shp In Sheets("Sheet2").Shapes
shp.Top = Sheets("Sheet1").Shapes(shp.Name).Top
shp.Left = Sheets("Sheet1").Shapes(shp.Name).Left
Next
End Sub


Regards,
Vic Eldridge
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
ActiveX Command Button - Snap to Cell Boundaries Paul Kraemer Excel Discussion (Misc queries) 2 February 9th 10 09:15 PM
Excel object in word document; some cell borders are too dark michalaw Excel Discussion (Misc queries) 0 July 11th 08 07:34 PM
Snap an object to a cell border via macro Brettjg Excel Discussion (Misc queries) 9 May 1st 07 02:10 PM
Borders Object DejaVu[_32_] Excel Programming 3 June 30th 05 10:24 PM
snap to from vba jngi[_2_] Excel Programming 5 June 18th 04 03:05 PM


All times are GMT +1. The time now is 02:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"