ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Form a circle (ie. color specific cells) given specific radius (https://www.excelbanter.com/excel-programming/357873-form-circle-ie-color-specific-cells-given-specific-radius.html)

David

Form a circle (ie. color specific cells) given specific radius
 
I am trying to create a circle (ie. color specific cells in a spreadsheet)
based on a certain diameter (ie. 100 cells). This could be code (formula)
written in Visual Basic that would use the given diameter and automatically
selects cells to leave out of the circle (different color). I was wondering
if this is some way that has already been implemented previously or if there
is a formula (circle equation I believe, R^2 = X^2 + Y^2) that I could use in
VB and automatically apply it to spreadsheet cells and only color the cells
that would form a circle and leave other cells as is?

Your help is very much appreciated.

Gary''s Student

Form a circle (ie. color specific cells) given specific radius
 
Do you wish to color the interior of the circle or only its boundary?
--
Gary''s Student


"David" wrote:

I am trying to create a circle (ie. color specific cells in a spreadsheet)
based on a certain diameter (ie. 100 cells). This could be code (formula)
written in Visual Basic that would use the given diameter and automatically
selects cells to leave out of the circle (different color). I was wondering
if this is some way that has already been implemented previously or if there
is a formula (circle equation I believe, R^2 = X^2 + Y^2) that I could use in
VB and automatically apply it to spreadsheet cells and only color the cells
that would form a circle and leave other cells as is?

Your help is very much appreciated.


David

Form a circle (ie. color specific cells) given specific radius
 
Thanks for your help Gary,
The problem I am having is not how to color cells , it is what cells to
automatically select to create a circle, so when I color them, I would be
able to see the circle shape.
I think that I will need to decide on the size of the cell (ie. 1point wide
cell = x inch), then how many cells would fit in my desired diameter based on
the width set for all cells, then have a formula that would exclude some of
the cells on the outside of my circle and color them.
I am thinking that this is a visual basic code that needs to include all the
parameters mentioned above (cell size, diameter (how many cells), formula to
decide what cells to exclude then color them(so the coloring is just to
differentiate between the included and excluded cells in order to form a
circle)
I was wondering if somebody has already implemented some code to create a
circle based on parameters mentioned above.

Regards,
Dave


"Gary''s Student" wrote:

Do you wish to color the interior of the circle or only its boundary?
--
Gary''s Student


"David" wrote:

I am trying to create a circle (ie. color specific cells in a spreadsheet)
based on a certain diameter (ie. 100 cells). This could be code (formula)
written in Visual Basic that would use the given diameter and automatically
selects cells to leave out of the circle (different color). I was wondering
if this is some way that has already been implemented previously or if there
is a formula (circle equation I believe, R^2 = X^2 + Y^2) that I could use in
VB and automatically apply it to spreadsheet cells and only color the cells
that would form a circle and leave other cells as is?

Your help is very much appreciated.


Gary''s Student

Form a circle (ie. color specific cells) given specific radius
 
This routine calculates the distance from CV1000 (the center) and colors
cells that are within a circle. Of course, column width must be adjusted to
give the circular appearance:


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
--
Gary''s Student


"David" wrote:

Thanks for your help Gary,
The problem I am having is not how to color cells , it is what cells to
automatically select to create a circle, so when I color them, I would be
able to see the circle shape.
I think that I will need to decide on the size of the cell (ie. 1point wide
cell = x inch), then how many cells would fit in my desired diameter based on
the width set for all cells, then have a formula that would exclude some of
the cells on the outside of my circle and color them.
I am thinking that this is a visual basic code that needs to include all the
parameters mentioned above (cell size, diameter (how many cells), formula to
decide what cells to exclude then color them(so the coloring is just to
differentiate between the included and excluded cells in order to form a
circle)
I was wondering if somebody has already implemented some code to create a
circle based on parameters mentioned above.

Regards,
Dave


"Gary''s Student" wrote:

Do you wish to color the interior of the circle or only its boundary?
--
Gary''s Student


"David" wrote:

I am trying to create a circle (ie. color specific cells in a spreadsheet)
based on a certain diameter (ie. 100 cells). This could be code (formula)
written in Visual Basic that would use the given diameter and automatically
selects cells to leave out of the circle (different color). I was wondering
if this is some way that has already been implemented previously or if there
is a formula (circle equation I believe, R^2 = X^2 + Y^2) that I could use in
VB and automatically apply it to spreadsheet cells and only color the cells
that would form a circle and leave other cells as is?

Your help is very much appreciated.


David

Form a circle (ie. color specific cells) given specific radius
 
Thanks gary, that worked.

"Gary''s Student" wrote:

This routine calculates the distance from CV1000 (the center) and colors
cells that are within a circle. Of course, column width must be adjusted to
give the circular appearance:


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
--
Gary''s Student


"David" wrote:

Thanks for your help Gary,
The problem I am having is not how to color cells , it is what cells to
automatically select to create a circle, so when I color them, I would be
able to see the circle shape.
I think that I will need to decide on the size of the cell (ie. 1point wide
cell = x inch), then how many cells would fit in my desired diameter based on
the width set for all cells, then have a formula that would exclude some of
the cells on the outside of my circle and color them.
I am thinking that this is a visual basic code that needs to include all the
parameters mentioned above (cell size, diameter (how many cells), formula to
decide what cells to exclude then color them(so the coloring is just to
differentiate between the included and excluded cells in order to form a
circle)
I was wondering if somebody has already implemented some code to create a
circle based on parameters mentioned above.

Regards,
Dave


"Gary''s Student" wrote:

Do you wish to color the interior of the circle or only its boundary?
--
Gary''s Student


"David" wrote:

I am trying to create a circle (ie. color specific cells in a spreadsheet)
based on a certain diameter (ie. 100 cells). This could be code (formula)
written in Visual Basic that would use the given diameter and automatically
selects cells to leave out of the circle (different color). I was wondering
if this is some way that has already been implemented previously or if there
is a formula (circle equation I believe, R^2 = X^2 + Y^2) that I could use in
VB and automatically apply it to spreadsheet cells and only color the cells
that would form a circle and leave other cells as is?

Your help is very much appreciated.


David

Form a circle (ie. color specific cells) given specific radius
 
Hi,
How easy would it be to save this circle selection (as a range) and have it
fit in excel spreadsheet window that would appear so I do not have to look
for it.
this is because the circle is going to be different size each time I run the
program with different circle dimensions.
Thanks for your help,
Dave

"David" wrote:

Thanks gary, that worked.

"Gary''s Student" wrote:

This routine calculates the distance from CV1000 (the center) and colors
cells that are within a circle. Of course, column width must be adjusted to
give the circular appearance:


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
--
Gary''s Student


"David" wrote:

Thanks for your help Gary,
The problem I am having is not how to color cells , it is what cells to
automatically select to create a circle, so when I color them, I would be
able to see the circle shape.
I think that I will need to decide on the size of the cell (ie. 1point wide
cell = x inch), then how many cells would fit in my desired diameter based on
the width set for all cells, then have a formula that would exclude some of
the cells on the outside of my circle and color them.
I am thinking that this is a visual basic code that needs to include all the
parameters mentioned above (cell size, diameter (how many cells), formula to
decide what cells to exclude then color them(so the coloring is just to
differentiate between the included and excluded cells in order to form a
circle)
I was wondering if somebody has already implemented some code to create a
circle based on parameters mentioned above.

Regards,
Dave


"Gary''s Student" wrote:

Do you wish to color the interior of the circle or only its boundary?
--
Gary''s Student


"David" wrote:

I am trying to create a circle (ie. color specific cells in a spreadsheet)
based on a certain diameter (ie. 100 cells). This could be code (formula)
written in Visual Basic that would use the given diameter and automatically
selects cells to leave out of the circle (different color). I was wondering
if this is some way that has already been implemented previously or if there
is a formula (circle equation I believe, R^2 = X^2 + Y^2) that I could use in
VB and automatically apply it to spreadsheet cells and only color the cells
that would form a circle and leave other cells as is?

Your help is very much appreciated.



All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com