Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Lots of single clickable cells

Hi,

For my sheet, I have followed John Walkenbachs tip to place rectangles
over cells and assign macro's to them to get a 'single click handler'
as described in http://j-walk.com/ss/excel/tips/tip12.htm

I have done this for a range of 12 rows and 12 columns. When one of
the cells is clicked, I show a userform where the user can enter some
data, I perform some calculations and the result must be placed in the
cell under the rectangle. Now when the macro is called, I want to know
which rectangle was clicked, or more important, which cell is
underneath! Offcourse I don't want to create 144 macro's to handle all
cells separately. So, how can I determine (in my macro) which
rectangle was clicked and find the underlying cell?

Here is my code:

' Adds rectangles to range
Sub AddRectangle()
Dim cell As Range

If Worksheets(1).ProtectDrawingObjects Then
MsgBox "Unprotect the sheet first."
Exit Sub
End If

' Maak vierkant aan
For Each cell In Range("Uitslagen")
Worksheets(1).Rectangles.Add(cell.Left, cell.Top, cell.Width,
cell.Height).Select
Selection.Interior.ColorIndex = xlNone
Selection.Border.LineStyle = xlNone
Selection.OnAction = "ShowResultDialog"
Next
End Sub

Sub ShowResultDialog()
' TODO: Find clicked rectangle
' TODO: Find cell under clicked rectangle
UserFormSetResult.Show
End Sub


Thanks for any suggestions.
Ronald
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Lots of single clickable cells

Ronald...

This works for me

Sub MacroCalledFromRectangle()
Dim s As Shape
Dim r As Range
Set s = ActiveSheet.Shapes(Application.Caller)
Set r = s.TopLeftCell
End Sub

HTH


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Ronald Moolenaar) wrote:

Hi,

For my sheet, I have followed John Walkenbachs tip to place rectangles
over cells and assign macro's to them to get a 'single click handler'
as described in
http://j-walk.com/ss/excel/tips/tip12.htm

I have done this for a range of 12 rows and 12 columns. When one of
the cells is clicked, I show a userform where the user can enter some
data, I perform some calculations and the result must be placed in the
cell under the rectangle. Now when the macro is called, I want to know
which rectangle was clicked, or more important, which cell is
underneath! Offcourse I don't want to create 144 macro's to handle all
cells separately. So, how can I determine (in my macro) which
rectangle was clicked and find the underlying cell?

Here is my code:

' Adds rectangles to range
Sub AddRectangle()
Dim cell As Range

If Worksheets(1).ProtectDrawingObjects Then
MsgBox "Unprotect the sheet first."
Exit Sub
End If

' Maak vierkant aan
For Each cell In Range("Uitslagen")
Worksheets(1).Rectangles.Add(cell.Left, cell.Top, cell.Width,
cell.Height).Select
Selection.Interior.ColorIndex = xlNone
Selection.Border.LineStyle = xlNone
Selection.OnAction = "ShowResultDialog"
Next
End Sub

Sub ShowResultDialog()
' TODO: Find clicked rectangle
' TODO: Find cell under clicked rectangle
UserFormSetResult.Show
End Sub


Thanks for any suggestions.
Ronald


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Lots of single clickable cells

Hi, Ive tried this but it doesnt seem to produce a range
as the return value ? how do you get the address of the
cell from this ?


-----Original Message-----
Ronald...

This works for me

Sub MacroCalledFromRectangle()
Dim s As Shape
Dim r As Range
Set s = ActiveSheet.Shapes(Application.Caller)
Set r = s.TopLeftCell
End Sub

HTH


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Ronald Moolenaar) wrote:

Hi,

For my sheet, I have followed John Walkenbachs tip to

place rectangles
over cells and assign macro's to them to get a 'single

click handler'
as described in http://j-

walk.com/ss/excel/tips/tip12.htm

I have done this for a range of 12 rows and 12

columns. When one of
the cells is clicked, I show a userform where the user

can enter some
data, I perform some calculations and the result must

be placed in the
cell under the rectangle. Now when the macro is

called, I want to know
which rectangle was clicked, or more important, which

cell is
underneath! Offcourse I don't want to create 144

macro's to handle all
cells separately. So, how can I determine (in my

macro) which
rectangle was clicked and find the underlying cell?

Here is my code:

' Adds rectangles to range
Sub AddRectangle()
Dim cell As Range

If Worksheets(1).ProtectDrawingObjects Then
MsgBox "Unprotect the sheet first."
Exit Sub
End If

' Maak vierkant aan
For Each cell In Range("Uitslagen")
Worksheets(1).Rectangles.Add(cell.Left,

cell.Top, cell.Width,
cell.Height).Select
Selection.Interior.ColorIndex = xlNone
Selection.Border.LineStyle = xlNone
Selection.OnAction = "ShowResultDialog"
Next
End Sub

Sub ShowResultDialog()
' TODO: Find clicked rectangle
' TODO: Find cell under clicked rectangle
UserFormSetResult.Show
End Sub


Thanks for any suggestions.
Ronald


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Lots of single clickable cells

Application.Caller, that's it! Thanks a lot.

Ronald

keepitcool wrote in message .. .
Ronald...

This works for me

Sub MacroCalledFromRectangle()
Dim s As Shape
Dim r As Range
Set s = ActiveSheet.Shapes(Application.Caller)
Set r = s.TopLeftCell
End Sub

HTH


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Ronald Moolenaar) wrote:

Hi,

For my sheet, I have followed John Walkenbachs tip to place rectangles
over cells and assign macro's to them to get a 'single click handler'
as described in
http://j-walk.com/ss/excel/tips/tip12.htm

I have done this for a range of 12 rows and 12 columns. When one of
the cells is clicked, I show a userform where the user can enter some
data, I perform some calculations and the result must be placed in the
cell under the rectangle. Now when the macro is called, I want to know
which rectangle was clicked, or more important, which cell is
underneath! Offcourse I don't want to create 144 macro's to handle all
cells separately. So, how can I determine (in my macro) which
rectangle was clicked and find the underlying cell?

Here is my code:

' Adds rectangles to range
Sub AddRectangle()
Dim cell As Range

If Worksheets(1).ProtectDrawingObjects Then
MsgBox "Unprotect the sheet first."
Exit Sub
End If

' Maak vierkant aan
For Each cell In Range("Uitslagen")
Worksheets(1).Rectangles.Add(cell.Left, cell.Top, cell.Width,
cell.Height).Select
Selection.Interior.ColorIndex = xlNone
Selection.Border.LineStyle = xlNone
Selection.OnAction = "ShowResultDialog"
Next
End Sub

Sub ShowResultDialog()
' TODO: Find clicked rectangle
' TODO: Find cell under clicked rectangle
UserFormSetResult.Show
End Sub


Thanks for any suggestions.
Ronald

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
Pulling a cell reference--clickable cells? Bermie Excel Worksheet Functions 1 April 16th 10 09:33 AM
Clickable Cells JSnow Excel Discussion (Misc queries) 2 September 25th 08 04:50 PM
automate the colouring of lots of cells [email protected] Excel Discussion (Misc queries) 1 September 26th 06 10:42 AM
adding lots of cells from different sheets dodgyone Excel Worksheet Functions 2 September 26th 05 04:23 PM
Cells containing lots of text will not wrap? Jon Parker Excel Discussion (Misc queries) 1 April 19th 05 01:25 PM


All times are GMT +1. The time now is 04:18 AM.

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"