ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Display VB code result in cell instead of message box? (https://www.excelbanter.com/excel-programming/428150-re-display-vbulletin-code-result-cell-instead-message-box.html)

Jacob Skaria

Display VB code result in cell instead of message box?
 
Please reivew your previous post

------------------
I assume the checkbox names are checkbox1, checkbox2 and so on..Launch VBE
using Alt+F11. Insert a module and paste the below code..

In worksheet the below formula will return the value
=GetCheckBoxValue()

Function GetCheckBoxValue() As Long
For intTemp = 1 To 4
If ActiveSheet.OLEObjects("CheckBox" & intTemp).Object.Value = True Then
GetCheckBoxValue = GetCheckBoxValue + 1
End If
Next
End Function


If this post helps click Yes
---------------
Jacob Skaria


"Leigh Douglass" wrote:

Is it possible to get the result of the code below to show in a cell on my
spreadsheet instead of displaying in a message box?

Thanks
Leigh

Private Sub GetResult()
' counter
MsgBox -1 * (CheckBox1 + CheckBox2 + CheckBox3 + CheckBox4)
' binary encoded
MsgBox -1 * (CheckBox1 + CheckBox2 + CheckBox3 + CheckBox4)
End Sub



All times are GMT +1. The time now is 10:33 AM.

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