Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to locate Cell in which control resides

Hello,

I need help getting VBA to recognize the cell in which a checkbox
resides. Is there a way to know the cell position based on the
location of the control. The code I am using is:

With ActiveCell.Interior
If CheckBox1.Value = True Then
.Color = RGB(0, 255, 0)
Else
.Color = RGB(255, 0, 0)
End If
End With

I basically need to change the color of the cell based on whether the
control is checked or not.

Thanks very much in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to locate Cell in which control resides

Hi Jamal,

Try something like:

'=============
Private Sub CheckBox1_Click()
Dim Rng As Range

Set Rng = Me.CheckBox1.TopLeftCell

With Rng.Interior
If Me.CheckBox1.Value = True Then
.ColorIndex = 4
Else
.ColorIndex = 3
End If
End With
End Sub
'<<=============

---
Regards,
Norman


"Jamal" wrote in message
ups.com...
Hello,

I need help getting VBA to recognize the cell in which a checkbox
resides. Is there a way to know the cell position based on the
location of the control. The code I am using is:

With ActiveCell.Interior
If CheckBox1.Value = True Then
.Color = RGB(0, 255, 0)
Else
.Color = RGB(255, 0, 0)
End If
End With

I basically need to change the color of the cell based on whether the
control is checked or not.

Thanks very much in advance.



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
Identify the row in which a MAX number in a column resides BarDoomed Excel Worksheet Functions 7 June 5th 08 08:23 PM
VLOOKUP when a range resides in Column A rpalarea Excel Discussion (Misc queries) 1 June 19th 07 08:40 PM
Determining Row in Which Labeled Cell Resides Chaplain Doug Excel Programming 3 May 11th 06 08:39 PM
VBA - Open Folder Where .xls Resides ajocius[_29_] Excel Programming 5 September 25th 05 05:16 PM
Locate max value cell Kevin Excel Programming 1 December 10th 03 05:05 PM


All times are GMT +1. The time now is 07:16 AM.

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

About Us

"It's about Microsoft Excel"