click to change value, one cell at a time, across a small matrix of cells

Mike McLaren

New Member
Joined
May 30, 2018
Messages
3
Greetings, guys. May I impose to ask for help on a personal project, please?

I've got a small 5x7 grid of cells in a spreadsheet that I use to edit fonts for an OLED display. Basically, I put a null or a 1 value in each cell (the cell color changes to black for a 1) and I use the resulting pattern to build the byte pattern data for my microcontroller projects.

Is there a way I can simply point and click on each cell in that 5x7 grid to toggle the cells value between a null value and a 1 value?

TIA. Cheerful regards, Mike
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You never said what area the 5-7 grid was so modify this Range:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

This script runs any time you enter a cell within the range
You will see my Range in red modify this as needed


Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Modified 5/30/18 9:50 PM EDT
If Not Intersect(Target, Range("[COLOR=#ff0000]C4:G10[/COLOR]")) Is Nothing Then
If Target.Cells.CountLarge > 1 Then Exit Sub
If Target.Value = "1" Then
Target.Value = ""
Else
Target.Value = "1"
End If
End If
End Sub
 
Upvote 0
Thank you so much. That works great. The clicked cell toggles and changes color nicely but it remains selected. Is there a way to deselect the target cell after affecting the change?

Thank you again... Mike
 
Upvote 0
Thank you so much. That works great. The clicked cell toggles and changes color nicely but it remains selected. Is there a way to deselect the target cell after affecting the change?

Thank you again... Mike

Some cell has to be selected. What cell do you want selected?
Do you want Range("A1") selected?
 
Upvote 0
Try this:
Range("A1") will now be selected
Cells(1,1) equals Row(1) column(1)
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Modified 5/31/18 1:15 AM EDT
If Not Intersect(Target, Range("C4:G10")) Is Nothing Then
If Target.Cells.CountLarge > 1 Then Exit Sub
If Target.Value = "1" Then
Target.Value = "": Cells(1, 1).Select
Else
Target.Value = "1": Cells(1, 1).Select
End If
End If
End Sub
 
Upvote 0
Just curious.
How do the cell colors change?
Is this caused by Conditional formatting?
The script could do all of this if you wanted.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Modified 5/31/18 1:35 AM EDT
If Not Intersect(Target, Range("C4:G10")) Is Nothing Then
If Target.Cells.CountLarge > 1 Then Exit Sub
If Target.Value = "1" Then
Target.Value = "": Target.Interior.Color = xlNone: Cells(1, 1).Select
Else
Target.Value = "1": Target.Interior.Color = vbBlack: Cells(1, 1).Select
End If
End If
End Sub
 
Upvote 0
Ok, some cell has to be selected. Gosh, that makes sense. I'll select one just outside the little 5x7 edit area.

Yes, I used Conditional Formatting to color the cells in the little 5x7 editing cell matrix and also in a 96 character Font Preview area.

Again, thank you very much...

Cheerful regards, Mike, K8LH
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
Ok, some cell has to be selected. Gosh, that makes sense. I'll select one just outside the little 5x7 edit area.

Yes, I used Conditional Formatting to color the cells in the little 5x7 editing cell matrix and also in a 96 character Font Preview area.

Again, thank you very much...

Cheerful regards, Mike, K8LH
 
Upvote 0

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top