#1
|
|||
|
|||
Insert increase number button
Hi
I am quite new to VBA and haven't had much luck finding a solution to this online. For context: I have created a 25 by 4 (x,y) table with headers in the first row and first column. The column lists specific products, while the row has different categories. I have to write down the amount of delivered products in their respective row/column. Is it possible for me to insert an invisible button in each cell (that will pop up when I hover over it) with an option to increase the amount? The base number being <empty> instead of "0", as empty rows will need to be removed by a macros I created. And to be greedy, can I add a shortcut key to each cell that I want to increase in amount? E.g. Apple - Thomas would be CTRL + 1 + 2 as Apple is the first product and Thomas is the second category. This would increase the cell to "1", and if I use the shortcut key again, it'll increase to 2 etc... Thank you in advance for your help. Greetings Just an example: |
#2
|
|||
|
|||
The answer to your basic question is no. However, you can add a plain text content control to your cells and use something like the following in the VB Project ThisDocument module:
Code:
Option Explicit Dim oCCTarget As ContentControl Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl) Set oCCTarget = ContentControl End Sub Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Set oCCTarget = Nothing End Sub Sub Increment() If Not oCCTarget Is Nothing Then Select Case oCCTarget.Range.Text Case Is = vbNullString oCCTarget.Range.Text = 1 Case Else If IsNumeric(oCCTarget.Range.Text) Then oCCTarget.Range.Text = Val(oCCTarget.Range.Text) + 1 Else oCCTarget.Range.Text = 1 End If End Select End If lbl_Exit: Exit Sub End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how can you have the the number of a document sequentially increase - QR Bar code | mattyA1977 | Word | 2 | 01-28-2020 05:50 AM |
Looking for a macro to increase a number by 1 in a Word document | Olopocram | Word VBA | 15 | 03-07-2018 05:39 PM |
increase the size of the insert hyperlink dialog box | mswmacroman | Word | 3 | 02-16-2017 01:44 AM |
How to increase Spin Button by .1 decimal | KangarooJack | Word VBA | 3 | 12-08-2015 05:50 AM |
Increase serial number for every print | atomtm | Word | 1 | 06-15-2012 05:39 AM |