473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Excel Help

Quick question. Is it possible to insert values in a cell with a checkbox checked? Say I have a checkbox and if the check box is checked I want to insert a persons initials into the cell.
I want to insert those initials in a column if it is checked, if it isnt checked nothing is inserted..

please help!!

Thanks!
Jul 28 '14 #1
5 1135
zmbd
5,501 Expert Mod 4TB
Yes, you would use VBA.
What you need to tell me is how you are using the checkbox.
Are you using a form (opened the VBA Editor and created the form)
OR
did you insert the checkbox on the worksheet....

In either case, you will need to check the value of the checkbox (true or false) and then determine which cell to enter the information.
Jul 28 '14 #2
Thanks for getting back to me.

I inserted the checkbox into the worksheet.
Jul 28 '14 #3
zmbd
5,501 Expert Mod 4TB
OK, Great! Next, which version of Office?

Next we need to know if you inserted the Form version of the control or the activex... this is easy.... right click on the control. If in the popup you see the entry "View Code" then you have the activex version, if not then the form version of the control is most likely.

In either case the basic code is going to be to check the value of the control and either enter the information or clear the information from the cell. (Personally, I'd give the cell a range name. This way, if you need to change the location of the intials, you simply use the range name manager to change the cell location; thus, no need to edit the code (^_^) )

--- just a heads up... I'm about to get bogged down here at work so there may be some delays from here on out (O_o)
Jul 28 '14 #4
I have Excel 2013.
I believe I have Form Version whoever, I can assign macro and edit the code.

that's fine, I'm at work as well.
Jul 28 '14 #5
zmbd
5,501 Expert Mod 4TB
Wonderful,
With the form version of the checkbox, everytime you toggle the state the assigned macro will run.

To refer to the control, you will refer to the worksheet's shapes collection... The fun part is that you have things like "Check Box 1" and "Check Box 3" etc... YUCK

Wouldn't be better to refer to the control via a normal name such as "chkbx_insertintials"... well this code will step thru all of the form-control checkbox formated shapes and allow you to change the name...

KEEP IN MIND THE FOLLOWING:
Access 2007 reserved words and symbols
AllenBrowne- Problem names and reserved words in Access

If you try to rename the controls using spaces or reserved charactors or reserved names, the control will not usually accept the new name.
(and for some reason it will not accept the original name either... strange)
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Sub Z_List_and_or_Rename_ChkBx()
  4.     Dim zwrkb As Workbook
  5.     Dim zwrks As Worksheet
  6.     Dim zshapes As Shapes
  7.     Dim zshape As Shape
  8.     Dim zprmpt As String
  9.     Dim zstr As String
  10.     '
  11.     Set zwrkb = ActiveWorkbook
  12.     Set zwrks = zwrkb.ActiveSheet
  13.     Set zshapes = zwrks.Shapes
  14.     '
  15.     On Error GoTo zerr
  16.     Debug.Print ">>"
  17.     For Each zshape In zshapes
  18.         With zshape
  19.             If .Type = msoFormControl Then
  20.                 If .FormControlType = xlCheckBox Then
  21.                     Debug.Print .Name, .ID, .AlternativeText, .ControlFormat.Value
  22.                     zprmpt = "Control with text: " & .AlternativeText & vbCrLf & _
  23.                         "ID Number: " & .ID & vbCrLf & _
  24.                         "Is Currently Named..."
  25.                     zstr = InputBox( _
  26.                         Prompt:=zprmpt, _
  27.                         Default:=.Name, Title:="Rename?")
  28.  
  29.                     If zstr = "" Or zstr = .Name Then
  30.                         .Name = .Name
  31.                     Else
  32.                         Debug.Print .Name & " Renamed to: ",
  33.                         .Name = zstr
  34.                         Debug.Print .Name
  35.                     End If
  36.                     '(Press <ctrl><g> to open the immediate window to see what is printing
  37.                 End If
  38.             End If
  39.         End With
  40.     Next
  41. '
  42. Debug.Print "<<"
  43.     Set zshapes = Nothing
  44.     Set zwrks = Nothing
  45.     Set zwrkb = Nothing
  46.  
  47. Exit Sub
  48. zerr:
  49.    Debug.Print Err.Description
  50.    Resume Next
  51. End Sub 
To use, simply copy and paste into the workbook into a standard module...
Select the worksheet with the controls of interest...
Enter your text next to each control...
then run the code as you would another macro

Now either keep track of the original names... you can copy and past from the immedates window into a textfile... or rename as needed. You will need to refer to control name to determine the value and therefor to toggle the intials.
Jul 28 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: steve | last post by:
Hi, I have generated a datagrid with the following columns: | Date-Time | Station ID | Parameter1 | .... | Parameter 2| I would like to: Create an Excel file and preferably give the user...
6
samycbe
by: samycbe | last post by:
Hi Friends, I want to open the excel and show the print dialouge box in excel when a command button click on vb. Please help me samy
6
by: jtswim01 | last post by:
I have a very basic issue in excel and I can't for the life of me find the solution. I have a dense worksheet of data and I want to distill some of the information into a much shorter list. The...
0
by: johnlim20088 | last post by:
Hi, Hi someone can help me on this? Currently I have a Listdata.aspx page with datagrid, I wish to export my datagrid content to excel with following code ( with button export click event):- ...
5
by: Louis | last post by:
I am trying to use php to update a spreadsheet (MS Excel or OpenOffice Calc) with data from MySQL. I looked into PEAR::Spreadsheet_Excel_Writer if it will do the job. If I understand it...
2
budigila
by: budigila | last post by:
Hiya peeps, Okies, I have been trying to work this out for a while now to no avail... I am a beginner to this whole coding thing but have made great strides in my project. Basically what I am...
1
by: JC2710 | last post by:
Hi I have a problem which I cant quite solve. I have a query that groups records together to get a Total Price..... Group....... Total Quantity............Price ...
10
KodeKrazy
by: KodeKrazy | last post by:
I'm trying to read an Excel worksheet and do a find/replace for all of the commas "," in any of the cells in the sheet and replace them with a dash "-" I can get as far as getting the workbook...
0
by: hitencontractor | last post by:
I am working on .NET Version 2003 making an SDI application that calls MS Excel 2003. I added a menu item called "MyApp Help" in the end of the menu bar to show Help-> About. The application...
9
by: MyWaterloo | last post by:
Hi all. I am asking this question here because I have no idea where else to go with it. It involves VBA... but not Access. You guys have always been spot on with Access help so i thought maybe you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.