Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2024, 05:12 AM
George24 George24 is offline Insert increase number button Windows 11 Insert increase number button Office 2021
Novice
Insert increase number button
 
Join Date: Jan 2024
Posts: 6
George24 is on a distinguished road
Default 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:
Attached Images
File Type: png sketch.PNG (4.4 KB, 11 views)
Reply With Quote
  #2  
Old 01-06-2024, 02:56 AM
gmaxey gmaxey is offline Insert increase number button Windows 10 Insert increase number button Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert increase number button how can you have the the number of a document sequentially increase - QR Bar code mattyA1977 Word 2 01-28-2020 05:50 AM
Insert increase number button Looking for a macro to increase a number by 1 in a Word document Olopocram Word VBA 15 03-07-2018 05:39 PM
Insert increase number button 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
Insert increase number button Increase serial number for every print atomtm Word 1 06-15-2012 05:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:10 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft