Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default assign a clickable macro to a cell?

Basically what I want to do is make it so that when a user clicks the
cell on sheet1 (kinda like a hyperlink), excel goes over to sheet2, and
selects a specific static index from a dropdown (which will then run
some other code that ive got going normally for when an item in that
combobox is clicked).

Im sure its possible and isnt too hard, I just havent done anything
like that before.


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default assign a clickable macro to a cell?

Hi
you'll need an event procedure for this (e.g. the worksheet_change
event). See the following site for more details about this:
http://www.cpearson.com/excel/events.htm

--
Regards
Frank Kabel
Frankfurt, Germany


Basically what I want to do is make it so that when a user clicks the
cell on sheet1 (kinda like a hyperlink), excel goes over to sheet2,
and selects a specific static index from a dropdown (which will then
run some other code that ive got going normally for when an item in
that combobox is clicked).

Im sure its possible and isnt too hard, I just havent done anything
like that before.


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default assign a clickable macro to a cell?

looks like i can probably use the workbook_selectionchange event and i
there say something like

if target = cell A4 then go to sheet2 and select xx value from th
combobox
if target = cell B4 then go to sheet2 and select xx value from th
combobox
if target = cell B5 then go to sheet2 and select xx value from th
combobox

etc etc for about 30 cells

just wondering if that would slow everything down a lot since it woul
be executing all that every single time any new cell is selected

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default assign a clickable macro to a cell?

Hi
if you restrict the range which you process in your macro it should be
o.k. I have such procedures in place and normally you wouldn't notice
the execution delay

--
Regards
Frank Kabel
Frankfurt, Germany


looks like i can probably use the workbook_selectionchange event and
in there say something like

if target = cell A4 then go to sheet2 and select xx value from the
combobox
if target = cell B4 then go to sheet2 and select xx value from the
combobox
if target = cell B5 then go to sheet2 and select xx value from the
combobox

etc etc for about 30 cells

just wondering if that would slow everything down a lot since it

would
be executing all that every single time any new cell is selected.


---
Message posted from http://www.ExcelForum.com/


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default assign a clickable macro to a cell?

hmm well the range will only be 30 specific cells which will remain th
same so thats 30 if statements executed every time a new cell i
selected :/ ill have to try it and see how slow it makes it, i do lik
to move around quite fast.

just trying to work out at the moment why im getting an erro saying su
or function not defined when i have the following code in sheet1

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.address = "$CA$7" Then
Worksheets("3.data").Select
ComboBox1.ListIndex = 25
ComboBox1_Click
End If
End Sub

it gives me the rror for the combobox1_click line, basically i want i
to select the correct item from the list (by setting the index to 25
and then make it think that item 25 was clicked so it performs th
click event as if it had been clicked normally. I did make th
combobox1_click public but its still giving me the error on that line.
the combobox1_click event is on the "3.data" sheets code, and thi
sheet gets selected in my above code before its trying to execute th
code for the click anyway

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default assign a clickable macro to a cell?

30 cells probably won't be noticeable, but you can use Intersect to
prescreen Target to make it more efficient:

Private Sub Worksheet_SelectionChange(ByVal Fred As Excel.Range)
With Fred
If .Count 1 Then Exit Sub 'more than one cell selected
If Not Intersect(.Cells, Range("A4,B4:B5,C15:J15")) _
Is Nothing Then
Select Case .Address(False, False)
Case "A4"
'do your selection
Case "B4"
'do your selection
'etc
End Select
End If
End With
End Sub

In article ,
neowok wrote:

looks like i can probably use the workbook_selectionchange event and in
there say something like

if target = cell A4 then go to sheet2 and select xx value from the
combobox
if target = cell B4 then go to sheet2 and select xx value from the
combobox
if target = cell B5 then go to sheet2 and select xx value from the
combobox

etc etc for about 30 cells

just wondering if that would slow everything down a lot since it would
be executing all that every single time any new cell is selected.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default assign a clickable macro to a cell?

ok thanks ill try that.

still having troulbe getting my simple bit fo code to work withou
errors

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "CA7" Then
Worksheets("3.data").Select
ComboBox1.ListIndex = 25
'ComboBox1_Click
end If
End Sub

first off i cant get it to work when the cell selected is CA7, the cod
above seems to ignore it even if i select CA7. if i uncomment th
combobox1_click line then it brings up an error on every cell clicked
highlighting "Private Sub Worksheet_SelectionChange(ByVal Target A
Range)"in yellow and combobox1_click in grey and the error again sau
sub or function not defined. no idea wots going on

--
Message posted from http://www.ExcelForum.com

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default assign a clickable macro to a cell?

You can't call an event macro (ComboBox1_Click) from a sub - it's fired
automatically when the combobox is clicked.

If you want to call the same code as when the combobox is clicked, put
the code in a separate sub in a regular code module, and call it from
both your Worksheet_SelectionChange and the ComboBox1_Click macros.


In article ,
neowok wrote:

ok thanks ill try that.

still having troulbe getting my simple bit fo code to work without
errors

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "CA7" Then
Worksheets("3.data").Select
ComboBox1.ListIndex = 25
'ComboBox1_Click
end If
End Sub

first off i cant get it to work when the cell selected is CA7, the code
above seems to ignore it even if i select CA7. if i uncomment the
combobox1_click line then it brings up an error on every cell clicked,
highlighting "Private Sub Worksheet_SelectionChange(ByVal Target As
Range)"in yellow and combobox1_click in grey and the error again saus
sub or function not defined. no idea wots going on.

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
Assign Macro to a Cell Bob Myers Excel Worksheet Functions 2 December 14th 09 07:35 PM
Formula or Macro to Assign Cell Locations econWGR Excel Discussion (Misc queries) 1 February 16th 07 02:57 AM
Forms: can a cell itself be clickable? Carmen Gauvin-O'Donnell New Users to Excel 1 August 17th 06 05:59 PM
Assign Macro to cell??? Ron de Bruin Excel Programming 1 August 8th 03 04:23 PM


All times are GMT +1. The time now is 04:08 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"