Gast
#250485
Wie kann ich in Excel unter VBA einen Button aktivieren.
Und zwar möchte ich das so haben:
Nach einer bestimmten Bedingung soll der Button automatisch gedrückt
(bestätigt) werden. Wie kann ich dies in VBA tun?
Ich habe es schon mit diesen Varianten ausprobiert:
cmdStopMonitor. = msoButtonSetOK
cmdStopMonitor.Enabled = True
-->funktioniert nicht.
Quellcode:
---------------------------------------------------------------------
---------------------------------------------------------------------
Public Sub update()
' this updates one row of data and then sets the timer for the
next reading
Dim timeString As String
On Error Resume Next
If continueMonitor Then ' the monitor function is on, set the
timer
' set the time for the next reading at 2 seconds
' set it first for best accuracy between measurements
' Note; setting for less than one second intervals may
' prevent the stop button from working
'intervalString = UserForm1.TextBox1.Text
If intervalString = "" Then
intervalString = TextBox1.Text
End If
nextTime = Now() + TimeValue("00:00:" + intervalString)
' Put the time relative to start time into the column 1
' the row is indicated by the global variable 'row'
ActiveSheet.Cells(row, 1).Select
Cells(row, 1).Value = Format$(Now() - startTime, "hh:nn:ss")
If Cells(row, 1).Text = "0" Then ' bad value
continueMonitor = False
Else
' Call the macro recorded with the toolbar
If CheckBox1.Value = True Then
MeasureDCVolts
End If
If CheckBox2.Value = True Then
CurrentDCAmpere
End If
' increment the row one down
row = row + 1
' now set the timer for the next reading
Application.OnTime nextTime, "sheet1.Update"
If anzahl_messwerteString = row Then
'cmdStopMonitor. = msoButtonSetOK
cmdStopMonitor.Enabled = True
End If
End If
End If
End Sub