ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Macro from specific cells (https://www.excelbanter.com/excel-programming/326740-run-macro-specific-cells.html)

Piers 2k

Run Macro from specific cells
 
Hi folks,

Tried searching the web for this, but don't know what event I'm searching
for!

I have a number of cells in a certain column (F9, F15, F16, F23....)
Non-contiguous. After the number is entered in these cells, I want it to
trigger a macro to effect the adjacent cell (bg colour and font colour)

I can construct the macro and assign it to a button, but I am unsure of how
to tie it to a specific cell or cells.

Anyone?

TIA,
Piers



Mike Fogleman

Run Macro from specific cells
 
It would be much simpler to use Conditional Format on the adjacent cells.

Mike F
"Piers 2k" wrote in message
...
Hi folks,

Tried searching the web for this, but don't know what event I'm searching
for!

I have a number of cells in a certain column (F9, F15, F16, F23....)
Non-contiguous. After the number is entered in these cells, I want it to
trigger a macro to effect the adjacent cell (bg colour and font colour)

I can construct the macro and assign it to a button, but I am unsure of
how
to tie it to a specific cell or cells.

Anyone?

TIA,
Piers





Tom Ogilvy

Run Macro from specific cells
 
Use the Change event (not SelectionChange)

right click on the sheet tab and select view code. then, from the dropdowns
at the top of the module:

Left: Worksheet
Right: Change

Private Sub Worksheet_Change(ByVal Target As Range)
if Target.count 1 then exit sub
set rng = Range("F9,F15:F16,F23")
if not intersect(Target,rng) is nothing then
With Target.Offset(0,1)
.Interior.colorIndex = 3
.Font.ColorIndex = 6
End Wtih
End if
End Sub

See Chip Pearson's page on Events
http://www.cpearson.com/excel/events.htm


--
Regards,
Tom Ogilvy

"Piers 2k" wrote in message
...
Hi folks,

Tried searching the web for this, but don't know what event I'm searching
for!

I have a number of cells in a certain column (F9, F15, F16, F23....)
Non-contiguous. After the number is entered in these cells, I want it to
trigger a macro to effect the adjacent cell (bg colour and font colour)

I can construct the macro and assign it to a button, but I am unsure of

how
to tie it to a specific cell or cells.

Anyone?

TIA,
Piers





Piers 2k

Run Macro from specific cells
 
Fab - thanks Tom.




All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com