Good Day,
I am not new to programming in VB but it has been a while since I have been doing more than just the basic macro builds. I have been asked to try and add some Ovals around designated cells within a worksheet. I would like to run one Macro and have it draw several ovals over the designated cells.
Currently the workbook has macros that will draw designated lines from Point A to Point B. I have tried to modify that code but It just did not seem to be working for me as I had wanted.
Found a few example that would draw the an oval around a SELECTED cell but I want to do a drawing code that is called from another Sub with designated Cell to have the oval drawn around. What I want is this:
But the Code has me selecting the cell, but with about 40 of these to insert I would like to do it with a drawing Sub - End Sub and a designated Sub- End Sub. The code that draws the above is:
Sub A_DrawOval2()
'Updateby20141105
Dim Arng As Range
Dim WorkRng As Range
Set WorkRng = Application.Selection
For Each Arng In WorkRng.Areas
With Arng
x = Arng.Height * 0.1
y = Arng.Width * 0.1
Application.ActiveSheet.Ovals.Add Top:=.Top - x, Left:=.Left - y, _
Height:=.Height + 2 * x, Width:=.Width + 1.5 * y
With Application.ActiveSheet.Ovals(ActiveSheet.Ovals.Count)
.Interior.ColorIndex = xlNone
.ShapeRange.Line.Weight = 1.25
End With
End With
Next
WorkRng.Select
End Sub
I want to use some code like this to call the drawing routing, to designate the cell/cells to draw around:
Sub A_DrawNewOval1_0()
Call A_DrawOval(D4, 8, 10)
End Sub
I know that is is a poor example but as I said I have not done much in the way of more comlex VBA code in a long time.
Thank you for any help in this matter.
I am not new to programming in VB but it has been a while since I have been doing more than just the basic macro builds. I have been asked to try and add some Ovals around designated cells within a worksheet. I would like to run one Macro and have it draw several ovals over the designated cells.
Currently the workbook has macros that will draw designated lines from Point A to Point B. I have tried to modify that code but It just did not seem to be working for me as I had wanted.
Found a few example that would draw the an oval around a SELECTED cell but I want to do a drawing code that is called from another Sub with designated Cell to have the oval drawn around. What I want is this:
But the Code has me selecting the cell, but with about 40 of these to insert I would like to do it with a drawing Sub - End Sub and a designated Sub- End Sub. The code that draws the above is:
Sub A_DrawOval2()
'Updateby20141105
Dim Arng As Range
Dim WorkRng As Range
Set WorkRng = Application.Selection
For Each Arng In WorkRng.Areas
With Arng
x = Arng.Height * 0.1
y = Arng.Width * 0.1
Application.ActiveSheet.Ovals.Add Top:=.Top - x, Left:=.Left - y, _
Height:=.Height + 2 * x, Width:=.Width + 1.5 * y
With Application.ActiveSheet.Ovals(ActiveSheet.Ovals.Count)
.Interior.ColorIndex = xlNone
.ShapeRange.Line.Weight = 1.25
End With
End With
Next
WorkRng.Select
End Sub
I want to use some code like this to call the drawing routing, to designate the cell/cells to draw around:
Sub A_DrawNewOval1_0()
Call A_DrawOval(D4, 8, 10)
End Sub
I know that is is a poor example but as I said I have not done much in the way of more comlex VBA code in a long time.
Thank you for any help in this matter.