Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 590
Default Positioning an Object (say a box) on a Excel cell

Using Visual Basic how can I position an object relative to the current cell
I am on. I don't know how to find the (points) position of the top corner of
this cell to the top left hand corner of the worksheet. Can someone supply
sample code

--
Ken
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Positioning an Object (say a box) on a Excel cell

Ken,

Sub PutItInPlace()
Dim rngPlace As Excel.Range
Set rngPlace = ActiveSheet.Range("B5")
With rngPlace
ActiveSheet.Shapes("Rectangle 1").Top = .Offset(3, 4).Top
ActiveSheet.Shapes("Rectangle 1").Left = .Offset(3, 4).Left
End With
Set rngPlace = Nothing
End Sub
End Sub

Jim Cone
San Francisco, USA


"Ken" wrote in message

Using Visual Basic how can I position an object relative to the current cell
I am on. I don't know how to find the (points) position of the top corner of
this cell to the top left hand corner of the worksheet. Can someone supply
sample code

--
Ken
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Positioning an Object (say a box) on a Excel cell

It may be worth noting that a shape such as a rectangle
has atleast the following properties:
..Top
..Left
..Height
..Width

and does not have the properties:
..Bottom
..Right

It may also be worth noting that
the zeroed quantites int he .offset propery
don't really matter. Example: It doesn't
matter if your setting the top of the rectangle
to the top of B5 or Z5. It will still align
with the top of row 5.

I've taken the previously posted code and made it a little more useful
by also aligning the bottom and right sides of the shape. This particular
example aligns it with the boundaries of a single cell.

Does anyone know how to make this update automatically
with the resizing of rows and columns?

Christmas May



Sub PutItInPlace()
Dim rngPlace As Excel.Range
Set rngPlace = ActiveSheet.Range("B5")
With rngPlace
'ActiveSheet.Shapes("Rectangle 1").Top = .Offset(2, 0).Top
'ActiveSheet.Shapes("Rectangle 1").Left = .Offset(0, 2).Left
ActiveSheet.Shapes("Rectangle 1").Top = .Offset(3, 0).Top
ActiveSheet.Shapes("Rectangle 1").Left = .Offset(0, 4).Left
ActiveSheet.Shapes("Rectangle 1").Height = .Offset(3, 4).Height
ActiveSheet.Shapes("Rectangle 1").Width = .Offset(3, 4).Width
End With
Set rngPlace = Nothing
End Sub



"Jim Cone" wrote:

Ken,

Sub PutItInPlace()
Dim rngPlace As Excel.Range
Set rngPlace = ActiveSheet.Range("B5")
With rngPlace
ActiveSheet.Shapes("Rectangle 1").Top = .Offset(3, 4).Top
ActiveSheet.Shapes("Rectangle 1").Left = .Offset(3, 4).Left
End With
Set rngPlace = Nothing
End Sub
End Sub

Jim Cone
San Francisco, USA


"Ken" wrote in message

Using Visual Basic how can I position an object relative to the current cell
I am on. I don't know how to find the (points) position of the top corner of
this cell to the top left hand corner of the worksheet. Can someone supply
sample code

--
Ken

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Positioning an Object (say a box) on a Excel cell

Figured it out. . . Right click on the rectangle and select the properties
tab. Several useful selections.

Sorry,

Christmas

"Christmas May" wrote:

It may be worth noting that a shape such as a rectangle
has atleast the following properties:
.Top
.Left
.Height
.Width

and does not have the properties:
.Bottom
.Right

It may also be worth noting that
the zeroed quantites int he .offset propery
don't really matter. Example: It doesn't
matter if your setting the top of the rectangle
to the top of B5 or Z5. It will still align
with the top of row 5.

I've taken the previously posted code and made it a little more useful
by also aligning the bottom and right sides of the shape. This particular
example aligns it with the boundaries of a single cell.

Does anyone know how to make this update automatically
with the resizing of rows and columns?

Christmas May



Sub PutItInPlace()
Dim rngPlace As Excel.Range
Set rngPlace = ActiveSheet.Range("B5")
With rngPlace
'ActiveSheet.Shapes("Rectangle 1").Top = .Offset(2, 0).Top
'ActiveSheet.Shapes("Rectangle 1").Left = .Offset(0, 2).Left
ActiveSheet.Shapes("Rectangle 1").Top = .Offset(3, 0).Top
ActiveSheet.Shapes("Rectangle 1").Left = .Offset(0, 4).Left
ActiveSheet.Shapes("Rectangle 1").Height = .Offset(3, 4).Height
ActiveSheet.Shapes("Rectangle 1").Width = .Offset(3, 4).Width
End With
Set rngPlace = Nothing
End Sub



"Jim Cone" wrote:

Ken,

Sub PutItInPlace()
Dim rngPlace As Excel.Range
Set rngPlace = ActiveSheet.Range("B5")
With rngPlace
ActiveSheet.Shapes("Rectangle 1").Top = .Offset(3, 4).Top
ActiveSheet.Shapes("Rectangle 1").Left = .Offset(3, 4).Left
End With
Set rngPlace = Nothing
End Sub
End Sub

Jim Cone
San Francisco, USA


"Ken" wrote in message

Using Visual Basic how can I position an object relative to the current cell
I am on. I don't know how to find the (points) position of the top corner of
this cell to the top left hand corner of the worksheet. Can someone supply
sample code

--
Ken

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
Comments positioning relative to cell not worksheet home For the Developers. Excel Discussion (Misc queries) 0 August 18th 06 07:12 PM
What is the deal with Comment Object Positioning? Mark Excel Discussion (Misc queries) 3 June 9th 05 11:05 PM
Positioning a cell at the top left of the screen Ben Excel Programming 4 May 14th 05 01:22 PM
vlookup to return the cell positioning where the criteria is found Rock Excel Programming 2 March 12th 05 03:42 PM
Positioning a graphical object Tom Ogilvy Excel Programming 0 July 27th 04 05:39 PM


All times are GMT +1. The time now is 05:15 AM.

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"