Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Draw a cirle

How do I draw a cirle in a cell when it is selected?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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" wrote in message
...
How do I draw a cirle in a cell when it is selected?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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" wrote in message
...
How do I draw a cirle in a cell when it is selected?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default 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" wrote in message
...
How do I draw a cirle in a cell when it is selected?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default 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" wrote in message
...

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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Draw a cirle


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:

Code:
--------------------

-'Check if user cell matches your cell choice-
If Target.Address = "$L$7" Then ...

-'Check If user cell is within your cell range-
Dim isect As Range
Set isect = Application.Intersect(Target, "$A$1:$M$25")
If isect is Not Nothing Then ...

-'Get Row and Column numbers of single cell Target-
Dim C As Long
Dim R As Long
With Target
C = .Column
R = .Row
End With

-'Get First Row, Last Row, First Column, and Last Column-
Dim FirstCol As Long
Dim LastCol As Long
Dim FirstRow As Long
Dim LastRow As Long

With Target
FirstCol = .Column
LastCol = .Columns.Count + FirstCol - 1
FirstRow = .Row
LastRow = .Rows.Count + FirstRow - 1
End With

--------------------

Hope this answers a few questions,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=482125

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to draw a pictograph? chen yu Charts and Charting in Excel 1 April 6th 09 04:01 PM
How draw x-y picture ZPXY Charts and Charting in Excel 1 December 13th 05 12:28 AM
Draw tool bar RW Excel Discussion (Misc queries) 1 May 18th 05 08:30 PM
Draw Buttons junx13[_14_] Excel Programming 3 September 23rd 04 01:06 AM
Draw Buttons junx13[_13_] Excel Programming 2 September 21st 04 01:57 PM


All times are GMT +1. The time now is 08:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"