+ Reply to Thread
Results 1 to 6 of 6

Draw a cirle

  1. #1
    Wayne
    Guest

    Draw a cirle

    How do I draw a cirle in a cell when it is selected?

  2. #2
    RB Smissaert
    Guest

    Re: Draw a cirle

    Easiest one:

    In the VBE right-click the worksheet, view code, and put in:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Target = "O"
    End Sub

    RBS

    "Wayne" <[email protected]> wrote in message
    news:[email protected]...
    > How do I draw a cirle in a cell when it is selected?



  3. #3
    Carlos
    Guest

    Re: Draw a cirle

    Hi Wayne try

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Call Circle_(Target)
    End Sub

    Sub Circle_(oCell As Range)

    l = oCell.Left
    t = oCell.Top
    h = oCell.Height
    w = oCell.Width

    Set Circlee = ActiveSheet.Shapes.AddShape(msoShapeOval, l, t, w, h)

    With Circlee
    .Fill.Solid
    .Fill.ForeColor.RGB = RGB(0, 0, 0)

    .Line.Weight = 0.5
    .Line.DashStyle = msoLineSolid
    .Line.Style = msoLineSingle
    .Line.ForeColor.RGB = RGB(255, 255, 255)
    .Line.BackColor.RGB = RGB(255, 255, 255)
    End With

    Set Circlee = Nothing
    End Sub

    more properties see Object browser

    "Wayne" <[email protected]> wrote in message
    news:[email protected]...
    > How do I draw a cirle in a cell when it is selected?




  4. #4
    Wayne
    Guest

    Re: Draw a cirle

    Hi Carlos
    Thanks for the help but I'm having problems getting this to work.

    Hoe do i set the target sell to "L7" for example?

    I tried inserting...

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Range("L7").Select
    Call Circle_(Target)
    End Sub




    "Carlos" wrote:

    > Hi Wayne try
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > Call Circle_(Target)
    > End Sub
    >
    > Sub Circle_(oCell As Range)
    >
    > l = oCell.Left
    > t = oCell.Top
    > h = oCell.Height
    > w = oCell.Width
    >
    > Set Circlee = ActiveSheet.Shapes.AddShape(msoShapeOval, l, t, w, h)
    >
    > With Circlee
    > .Fill.Solid
    > .Fill.ForeColor.RGB = RGB(0, 0, 0)
    >
    > .Line.Weight = 0.5
    > .Line.DashStyle = msoLineSolid
    > .Line.Style = msoLineSingle
    > .Line.ForeColor.RGB = RGB(255, 255, 255)
    > .Line.BackColor.RGB = RGB(255, 255, 255)
    > End With
    >
    > Set Circlee = Nothing
    > End Sub
    >
    > more properties see Object browser
    >
    > "Wayne" <[email protected]> wrote in message
    > news:[email protected]...
    > > How do I draw a cirle in a cell when it is selected?

    >
    >
    >


  5. #5
    Rowan Drummond
    Guest

    Re: Draw a cirle

    Hi Wayne

    The code Carlos gave you is worksheet event code so make sure that you
    have pasted it in the code module associated with the sheet not a normal
    module. Right click the sheet tab and select View Code to get the
    correct code sheet.

    Target is the range selected. The way Carlos had his code the circle
    will be drawn in whichever cell is selected. If you want a circle in L7
    any time the user clicks on a new cell then maybe:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Call Circle_(Range("L7"))
    End Sub

    Hope this helps
    Rowan

    Wayne wrote:
    > Hi Carlos
    > Thanks for the help but I'm having problems getting this to work.
    >
    > Hoe do i set the target sell to "L7" for example?
    >
    > I tried inserting...
    >
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > Range("L7").Select
    > Call Circle_(Target)
    > End Sub
    >
    >
    >
    >
    > "Carlos" wrote:
    >
    >
    >>Hi Wayne try
    >>
    >>Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    >> Call Circle_(Target)
    >>End Sub
    >>
    >>Sub Circle_(oCell As Range)
    >>
    >> l = oCell.Left
    >> t = oCell.Top
    >> h = oCell.Height
    >> w = oCell.Width
    >>
    >> Set Circlee = ActiveSheet.Shapes.AddShape(msoShapeOval, l, t, w, h)
    >>
    >> With Circlee
    >> .Fill.Solid
    >> .Fill.ForeColor.RGB = RGB(0, 0, 0)
    >>
    >> .Line.Weight = 0.5
    >> .Line.DashStyle = msoLineSolid
    >> .Line.Style = msoLineSingle
    >> .Line.ForeColor.RGB = RGB(255, 255, 255)
    >> .Line.BackColor.RGB = RGB(255, 255, 255)
    >> End With
    >>
    >> Set Circlee = Nothing
    >>End Sub
    >>
    >>more properties see Object browser
    >>
    >>"Wayne" <[email protected]> wrote in message
    >>news:[email protected]...
    >>
    >>>How do I draw a cirle in a cell when it is selected?

    >>
    >>
    >>


  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Wayne,

    This may help clear things up. The Worksheet_SelectionChange event is triggered when you select a cell on the worksheet. The "Target" is a range object that returns either a single cell or a group of cells that were selected.

    Here are a few ways to check if the user selected a certain cell or cells...

    Examples of Checking the Target:
    Please Login or Register  to view this content.
    Hope this answers a few questions,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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