ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check and uncheck a checkbox (https://www.excelbanter.com/excel-programming/359749-check-uncheck-checkbox.html)

NoProgram

Check and uncheck a checkbox
 

I used to be decent at VB, but it's been so many years now, and I can't
remember a lick of this stuff. I'm just trying to create a basic macro
that will do the following:

Start at cell A1 and the auto increment across the row until X
Check the Cell value for data
If there is data then I need it to physically check a checkbox (say
checkbox1)

Thank you in advance for anyone kind enough to lend an old timer a
hand, it's appreciated!

John


--
NoProgram
------------------------------------------------------------------------
NoProgram's Profile: http://www.excelforum.com/member.php...o&userid=33832
View this thread: http://www.excelforum.com/showthread...hreadid=536091


NickH

Check and uncheck a checkbox
 
John,

When you say 'auto increment across the row' are you actually putting
incremental numbers into the cells or are are you checking the value of
every cell or are you only interested in the value in X?

Is the checkbox in a userform or on the sheet?

A little more detail about what your trying to do, and maybe why, would
be useful.

Kind regards,
NickH


NoProgram[_2_]

Check and uncheck a checkbox
 

NickH Wrote:
John,

When you say 'auto increment across the row' are you actually putting
incremental numbers into the cells or are are you checking the value
of
every cell or are you only interested in the value in X?

Is the checkbox in a userform or on the sheet?

A little more detail about what your trying to do, and maybe why,
would
be useful.

Kind regards,
NickH


Hi Nick,

I want to check to see if there is data in the cell, if there is, then
it will tick off (or check) a checkbox, then increment the cell (if it
was on A1, then advance the B1), and repeat the process again.

And this is in a usersheet. I'm a teacher and I'm taking a web based
test that was created in a form and importing the comma dileminated
data into the excel spreedsheet, and then creating a macro that will
check the values and mark off the answers that were given.

Does that make it more clear? Thanks for your help.


--
NoProgram
------------------------------------------------------------------------
NoProgram's Profile: http://www.excelforum.com/member.php...o&userid=33832
View this thread: http://www.excelforum.com/showthread...hreadid=536091


NickH

Check and uncheck a checkbox
 
John,

This placed in a new module should give you a start. I've made certain
assumptions which I'll go through beneath the code...


Sub CheckValues() 'pun intended ;^)
Dim i As Integer

For i = 1 To 4 'i.e. will look at first 4 columns A, B, C & D
If Not Cells(1, i) = "" Then
Sheet1.OLEObjects("CheckBox" & i).Object.Value = 1
Else
Sheet1.OLEObjects("CheckBox" & i).Object.Value = 0
End If
Next i
End Sub

Assumptions:
The codename (not the tab name) of the sheet you are using is Sheet1
The answers you are checking are on row 1 starting at column 1
Each answer has an associated Checkbox, also on Sheet1, called
CheckBox1, CheckBox2 etc.
You are only checking that a value is present, not what it actually is

HTH
NickH



All times are GMT +1. The time now is 02:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com