ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB Code Based on Contents of a Shape (https://www.excelbanter.com/excel-programming/419380-vbulletin-code-based-contents-shape.html)

Lost

VB Code Based on Contents of a Shape
 
Since you cannot increase the size of an a checkbox in Excel, I'm making one
using VB.

Below is the code that I have compiled to allow the user to check/uncheck a
box...

However in addition to the code below, I need to add code to apply the
contents of the autoshape to a cell on my sheet, therefore if the box is
checked my cell will say true, otherwise it will say false. Please HELP!!!

Sub MyCheckbox_Click()
Dim strName As String
strName = Application.Caller
If Left(strName, 3) < "chk" Then strName = "chk" & strName
If ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = "" Then
ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = "ü"
Else
ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = ""
End If
End Sub


JLGWhiz

VB Code Based on Contents of a Shape
 
Not sure if this is what you want but it is one way to doi it.
Assume that Range("A1") is the range that displays "True" or "False"

Sub MyCheckbox_Click()
Dim strName As String
strName = Application.Caller
If Left(strName, 3) < "chk" Then strName = "chk" & strName
If ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = "" Then
ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = "ü"
ActiveSheet.Range("A1") = "True"
Else
ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = ""
ActiveSheet.Range("A1") = "False"
End If
End Sub










"Lost" wrote:

Since you cannot increase the size of an a checkbox in Excel, I'm making one
using VB.

Below is the code that I have compiled to allow the user to check/uncheck a
box...

However in addition to the code below, I need to add code to apply the
contents of the autoshape to a cell on my sheet, therefore if the box is
checked my cell will say true, otherwise it will say false. Please HELP!!!

Sub MyCheckbox_Click()
Dim strName As String
strName = Application.Caller
If Left(strName, 3) < "chk" Then strName = "chk" & strName
If ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = "" Then
ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = "ü"
Else
ActiveSheet.Shapes(strName).TextFrame.Characters.T ext = ""
End If
End Sub



All times are GMT +1. The time now is 02:35 AM.

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