1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VBA add circle to a cell

Discussion in 'Software Development' started by nczman, Sep 19, 2003.

Thread Status:
Not open for further replies.
  1. nczman

    nczman Thread Starter

    Joined:
    Dec 12, 2000
    Messages:
    310
    I am moving information from access to excel, and if the information in column j is greater or equal to 85, I am setting the font to bold. I have seen a spreadsheet that has placed a circle around the number instead of doing the bold. Manually, it would be autoshape,

    Has anyone ever added a circle using code??

    here is what I use.

    If rstLeader![Wait3Min] >= 85 Then
    .Range("j" & icol).Cells.Font.Bold = True
    End If

    Any ideas on how I could place a circle there instead?

    Thanks much
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    There is a sample for doing this in an Access report and I would think it would work in Excel just as well....just create the function and call it.


    Private Sub Detail0_Print(Cancel As Integer, PrintCount As Integer)

    ' Draw ellipse around controls that meet specified criteria.

    Dim ctl As Control
    Dim intPrintCircle As Integer
    Dim sngAspect As Single, sngYOffset As Single
    Dim intEllipseHeight As Integer, intElipseWidth As Integer
    Dim sngXCoord As Single, sngYCoord As Single
    Dim intI As Integer

    ' To yield desired ellipse, set sngAspect and sngYOffset
    ' according to the size and location of text boxes on

    ' subreport.
    sngAspect = 0.23
    sngYOffset = 200

    ' Determine height and width of ellipse.
    intEllipseHeight = Me!Goal.Height * 1.1
    intElipseWidth = Me!Goal.Width * 1.04
    sngYCoord = (Me!Goal.Top + Me!Goal.Height) \ 2 + sngYOffset

    ' Loop through the controls that could be circled.
    ' If ctl is not Null, then determine if value is 90% or
    ' greater than value in Goal text box.
    For intI = 1 To 4
    Set ctl = Me("Qtr" & intI)
    If Not IsNull(ctl) Then

    intPrintCircle = (ctl >= 0.9 * Me!Goal)

    ' Determine coordinates of ctl and draw ellipse.
    If intPrintCircle Then
    sngXCoord = ctl.Left + (ctl.Width \ 2)
    Me.Circle (sngXCoord, sngYCoord), intElipseWidth \ 2, , , , sngAspect
    End If
    End If
    Next intI

    End Sub
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/165994

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice