+ Reply to Thread
Results 1 to 6 of 6

how to creat userinputs freeform shape

  1. #1
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    how to creat userinputs freeform shape

    Dear all i want to create a free from or polygon shapes by cell inputs.as the values enters it create shape as per cell measurments in inches or cm .i did it by hiding/showing pics.but i want to draw a true shape as per given values to see effect.please view excel sheet for understanding
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: how to creat userinputs freeform shape

    Cross post

    http://www.ozgrid.com/forum/showthread.php?t=199502

  3. #3
    Registered User
    Join Date
    04-24-2016
    Location
    pakistan
    MS-Off Ver
    2011
    Posts
    8

    Re: how to creat userinputs freeform shape

    try this it will make any shape

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim nLeft As Double, nTop As Double, i As Long
    Dim shp As Shape, ShapeName As String, selRange As Range
    Dim nTopWidth As Double, nBottomWidth As Double, nLeftHeight As Double, nRightHeight As Double
    Set selRange = Selection
    ShapeName = "freeform" & Target.Row
    If Target.Column <= 5 And Target.Row() > 1 Then
    For Each shp In ActiveSheet.Shapes
    If shp.Name = ShapeName Then shp.Delete
    Next shp
    For i = 1 To Target.Row - 1
    nTop = nTop + Cells(i, 1).RowHeight
    Next i
    nTop = nTop + 21
    nLeft = 300
    nLeftHeight = Range("C" & Target.Row)
    nRightHeight = Range("D" & Target.Row)
    nTopWidth = Range("A" & Target.Row)
    nBottomWidth = Range("B" & Target.Row)
    Target.RowHeight = nLeftHeight + 21
    With ActiveSheet.Shapes.BuildFreeform(msoEditingAuto, nLeft, nTop)
    .AddNodes msoSegmentLine, msoEditingAuto, nLeft, nTop + nLeftHeight
    .AddNodes msoSegmentLine, msoEditingAuto, nBottomWidth + nLeft, nTop + nLeftHeight
    .AddNodes msoSegmentLine, msoEditingAuto, nBottomWidth + nLeft, nTop + nLeftHeight - nRightHeight
    .AddNodes msoSegmentLine, msoEditingAuto, nLeft + nTopWidth, nTop
    .AddNodes msoSegmentLine, msoEditingAuto, nLeft, nTop
    .ConvertToShape.Select
    Selection.Name = "freeform" & Target.Row
    End With
    End If
    selRange.Select
    End Sub

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: how to creat userinputs freeform shape

    Glad to see that you try to help, but pleae note that:

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

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/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
    Best Regards,

    Kaper

  5. #5
    Registered User
    Join Date
    04-24-2016
    Location
    pakistan
    MS-Off Ver
    2011
    Posts
    8

    Re: how to creat userinputs freeform shape

    ok boss,next time will take care

  6. #6
    Registered User
    Join Date
    04-04-2016
    Location
    pakistan
    MS-Off Ver
    2007
    Posts
    15

    Re: how to creat userinputs freeform shape

    thanks,you are right it creats,triangle,rectangle,poly

+ 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. [SOLVED] listbox and freeform text in one cell?
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-18-2013, 02:05 PM
  2. Freeform autoshape is automatically filling in
    By Lorrie3292 in forum Excel General
    Replies: 0
    Last Post: 10-26-2011, 09:32 AM
  3. Adding text to a freeform shape programmatically Excel VBA
    By waqas716 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2011, 07:57 AM
  4. Adding color to freeform scribble
    By wmorrison49 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-12-2008, 05:37 PM
  5. Changing color of node in freeform shape
    By jstansbury in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-02-2006, 11:05 AM
  6. [SOLVED] Pick list or freeform text
    By PJH in forum Excel General
    Replies: 2
    Last Post: 03-30-2006, 12:15 AM
  7. [SOLVED] How do I refer to a freeform name and number on a chart using VBA
    By Raas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-23-2005, 02:25 PM
  8. [SOLVED] Freeform shapes
    By Jackie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2005, 01:05 PM

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