+ Reply to Thread
Results 1 to 5 of 5

Circle in excel

  1. #1
    David
    Guest

    Circle in excel

    Hi,
    I am trying to create a circle by coloring excel cells.
    I knew that I needed to use circle equation to build a circle in excel.
    "Gary's student" user name, helped me out with the VB code show at the end.

    This works great if the row and col sizes are the same (which are inputs
    from the user), in other words, when the cells are square it works great.
    The problem I am having is that when ie. row height > col width, I get an
    elipse instead of a circle. The reason is that the code below colors the
    same number of col as rows (but row heigh > than col width).
    I need to somehow to control the code in a way that even if the row and col
    sizes are different, it alway creates a circle (number of cell in x direction
    do not have to be always the same as in the y direction as long as a circle
    shape is attained at the end)

    Is this something that could be done in Excel?
    Any ideas would be greatly appreciated.

    Sub asdf()
    For i = 900 To 1100
    For j = 50 To 150
    d = Sqr((i - 1000) ^ 2 + (j - 100) ^ 2)
    If d < 50 Then
    Cells(i, j).Interior.ColorIndex = 46
    End If
    Next
    Next
    End Sub

  2. #2
    ufo_pilot
    Guest

    RE: Circle in excel

    Try:

    Col width 1.6
    Rowheight 12.75

    "David" wrote:

    > Hi,
    > I am trying to create a circle by coloring excel cells.
    > I knew that I needed to use circle equation to build a circle in excel.
    > "Gary's student" user name, helped me out with the VB code show at the end.
    >
    > This works great if the row and col sizes are the same (which are inputs
    > from the user), in other words, when the cells are square it works great.
    > The problem I am having is that when ie. row height > col width, I get an
    > elipse instead of a circle. The reason is that the code below colors the
    > same number of col as rows (but row heigh > than col width).
    > I need to somehow to control the code in a way that even if the row and col
    > sizes are different, it alway creates a circle (number of cell in x direction
    > do not have to be always the same as in the y direction as long as a circle
    > shape is attained at the end)
    >
    > Is this something that could be done in Excel?
    > Any ideas would be greatly appreciated.
    >
    > Sub asdf()
    > For i = 900 To 1100
    > For j = 50 To 150
    > d = Sqr((i - 1000) ^ 2 + (j - 100) ^ 2)
    > If d < 50 Then
    > Cells(i, j).Interior.ColorIndex = 46
    > End If
    > Next
    > Next
    > End Sub


  3. #3
    ufo_pilot
    Guest

    RE: Circle in excel

    Actually on a close up a CELL looks more square on 2.0 in col width to a
    12.75 rowheight
    Try looking at it at 25% then changing ths column width to your satisfaction


    "David" wrote:

    > Hi,
    > I am trying to create a circle by coloring excel cells.
    > I knew that I needed to use circle equation to build a circle in excel.
    > "Gary's student" user name, helped me out with the VB code show at the end.
    >
    > This works great if the row and col sizes are the same (which are inputs
    > from the user), in other words, when the cells are square it works great.
    > The problem I am having is that when ie. row height > col width, I get an
    > elipse instead of a circle. The reason is that the code below colors the
    > same number of col as rows (but row heigh > than col width).
    > I need to somehow to control the code in a way that even if the row and col
    > sizes are different, it alway creates a circle (number of cell in x direction
    > do not have to be always the same as in the y direction as long as a circle
    > shape is attained at the end)
    >
    > Is this something that could be done in Excel?
    > Any ideas would be greatly appreciated.
    >
    > Sub asdf()
    > For i = 900 To 1100
    > For j = 50 To 150
    > d = Sqr((i - 1000) ^ 2 + (j - 100) ^ 2)
    > If d < 50 Then
    > Cells(i, j).Interior.ColorIndex = 46
    > End If
    > Next
    > Next
    > End Sub


  4. #4
    K Dales
    Guest

    RE: Circle in excel

    Sub asdf()
    Dim AspectRatio As Single
    AspectRatio = Cells(1, 1).Width / Cells(1, 1).Height
    For i = 900 To 1100
    For j = 50 To 150
    d = Sqr((i - 1000) ^ 2 + (j - 100) ^ 2)
    If d < 50 Then
    Cells(i, Int(j / AspectRatio)).Interior.ColorIndex = 46
    End If
    Next
    Next
    End Sub

    --
    - K Dales


    "David" wrote:

    > Hi,
    > I am trying to create a circle by coloring excel cells.
    > I knew that I needed to use circle equation to build a circle in excel.
    > "Gary's student" user name, helped me out with the VB code show at the end.
    >
    > This works great if the row and col sizes are the same (which are inputs
    > from the user), in other words, when the cells are square it works great.
    > The problem I am having is that when ie. row height > col width, I get an
    > elipse instead of a circle. The reason is that the code below colors the
    > same number of col as rows (but row heigh > than col width).
    > I need to somehow to control the code in a way that even if the row and col
    > sizes are different, it alway creates a circle (number of cell in x direction
    > do not have to be always the same as in the y direction as long as a circle
    > shape is attained at the end)
    >
    > Is this something that could be done in Excel?
    > Any ideas would be greatly appreciated.
    >
    > Sub asdf()
    > For i = 900 To 1100
    > For j = 50 To 150
    > d = Sqr((i - 1000) ^ 2 + (j - 100) ^ 2)
    > If d < 50 Then
    > Cells(i, j).Interior.ColorIndex = 46
    > End If
    > Next
    > Next
    > End Sub


  5. #5
    David
    Guest

    RE: Circle in excel

    I tried your code and some of the cells inside the circle do not get colored
    do you know why?

    Thanks for your help

    "K Dales" wrote:

    > Sub asdf()
    > Dim AspectRatio As Single
    > AspectRatio = Cells(1, 1).Width / Cells(1, 1).Height
    > For i = 900 To 1100
    > For j = 50 To 150
    > d = Sqr((i - 1000) ^ 2 + (j - 100) ^ 2)
    > If d < 50 Then
    > Cells(i, Int(j / AspectRatio)).Interior.ColorIndex = 46
    > End If
    > Next
    > Next
    > End Sub
    >
    > --
    > - K Dales
    >
    >
    > "David" wrote:
    >
    > > Hi,
    > > I am trying to create a circle by coloring excel cells.
    > > I knew that I needed to use circle equation to build a circle in excel.
    > > "Gary's student" user name, helped me out with the VB code show at the end.
    > >
    > > This works great if the row and col sizes are the same (which are inputs
    > > from the user), in other words, when the cells are square it works great.
    > > The problem I am having is that when ie. row height > col width, I get an
    > > elipse instead of a circle. The reason is that the code below colors the
    > > same number of col as rows (but row heigh > than col width).
    > > I need to somehow to control the code in a way that even if the row and col
    > > sizes are different, it alway creates a circle (number of cell in x direction
    > > do not have to be always the same as in the y direction as long as a circle
    > > shape is attained at the end)
    > >
    > > Is this something that could be done in Excel?
    > > Any ideas would be greatly appreciated.
    > >
    > > Sub asdf()
    > > For i = 900 To 1100
    > > For j = 50 To 150
    > > d = Sqr((i - 1000) ^ 2 + (j - 100) ^ 2)
    > > If d < 50 Then
    > > Cells(i, j).Interior.ColorIndex = 46
    > > End If
    > > Next
    > > Next
    > > End Sub


+ 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