+ Reply to Thread
Results 1 to 2 of 2

shape positioning

Hybrid View

  1. #1
    Registered User
    Join Date
    11-08-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    45

    shape positioning

    I have the following code to create a bar a point and a pin

    Private Sub CommandButton1_Click()
    list_top = "AA1"
    For i = 1 To 100000
        shape_type = Range(list_top).Offset(i, 0).Value
        If shape_type = "" Then Exit Sub
        
        Select Case shape_type
            Case "bar"
                new_bar Range(list_top).Offset(i, 1).Value, Range(list_top).Offset(i, 2).Value, Range(list_top).Offset(i, 3).Value
            Case "point"
                new_point Range(list_top).Offset(i, 1).Value
            Case "pin"
                new_pin Range(list_top).Offset(i, 1).Value, Range(list_top).Offset(i, 2).Value
            
        End Select
    Next i
    End Sub
    Public Sub new_bar(ByVal bar_name As String, ByVal bar_width As Double, bar_length_pin_to_pin As Double)
    ActiveSheet.Shapes("_bar").Duplicate
    DoEvents
    ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name = bar_name
    ActiveSheet.Shapes(bar_name).Height = bar_width
    ActiveSheet.Shapes(bar_name).Width = bar_width + bar_length_pin_to_pin
    End Sub
    Public Sub new_point(ByVal point_name As String)
    ActiveSheet.Shapes("_point").Duplicate
    DoEvents
    ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name = point_name
    End Sub
    Public Sub new_pin(ByVal pin_name As String, ByVal statonary As Double)
    ActiveSheet.Shapes("_pin").Duplicate
    DoEvents
    ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name = pin_name
    ActiveSheet.Shapes(pin_name).Width = pin_diameter
    End Sub
    In Cell AA1 to AD5 i have the following

    Type Name
    bar __bar_2 20 120
    bar __bar_1 10 100
    point __point_1
    pin __pin_1 10

    A pin, bar and point are created with a width, height and diameter of the inputted values.

    I now what to have another button that positions these newly created shapes

    so in cell AI1 to AO5 I have

    where row 3 and 4 are the top and left coordinates

    Type Name
    bar __bar_1 100 100
    bar __bar_2 200 200
    point __point 200 200
    pin __pin 100 100 100

    any idea what the best way of doing this would be?

    cheers
    Last edited by Stanley91; 02-10-2014 at 08:55 AM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: shape positioning

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 13
    Last Post: 12-10-2013, 12:51 PM
  2. [SOLVED] Use a button to control a macro that inserts an image into a shape or resets the shape
    By nwb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2013, 04:41 PM
  3. Positioning Shape objects in a chart in relation to data points
    By bchandz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2013, 01:38 PM
  4. Add command button to shape and change shape color on mouseover
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2012, 05:12 PM
  5. Replies: 0
    Last Post: 11-30-2012, 01:29 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1