PDA

View Full Version : Checklist: When table cell is clicked, make it green / white (not headers)



jokris
03-23-2019, 10:34 AM
I have a simple table, 5 rows x 5 columns.
The uppermost row and the leftmost column contains headers

y y y y y
z x x x x
z x x x x
z x x x x

Each x cell contains some kind of text.

I want to create a simple checklist where if I click cell x, that cell will become green (if not green) and the text inside becomes white.
When I click the cell again, I want the green cell to revert back to white and the text to black

Also the file should automatically save (not save as) when cell is clicked.

I would like the macro to run directly when opening the powerpoint file.

Total newbie at VBA so don't know how to do this?

John Wilson
03-23-2019, 10:56 AM
That would be quite a job for a newbie

There's no way to click on a table cell and tell the code which cell has been clicked.

Probably the only way would be to have code that runs at the start of the show and adds transparent shapes over each cell to trigger the code and removes them again when the show terminated. Not at all easy!

Logit
03-24-2019, 09:58 AM
.
If I correctly understand your goal ... and albeit the below is for Excel .. hopefully it can transfer somehow to PowerPoint ?


I created a table from A1:E6 called TABLE1.

Then paste this macro into the worksheet module :



Option Explicit


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim Table1 As Range
Dim KeyCells As Range


If Not Intersect(Target, Range("A2:E6")) Is Nothing Then


With Table1
If Target.Cells.Interior.Color = vbWhite Then
Target.Cells.Interior.Color = vbGreen
Target.Cells.Font.Color = vbWhite
ElseIf Target.Cells.Interior.Color = vbGreen Then
Target.Cells.Interior.Color = vbWhite
Target.Cells.Font.Color = vbBlack
End If
End With


Else


Exit Sub


End If



End Sub

John Wilson
03-24-2019, 11:51 AM
You cannot use code like that in PowerPoint sadly.