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
Das stimmt nicht --> cmdStopMonitor. = msoButtonSetOK Ich habe mich verschrieben, so steht es bei mir --> cmdStopMonitor.Button = msoButtonSetOK
Soll nur die Funktion die sich hinter diesem Button verbirgt aufgerufen werden oder willst Du den Button aktivieren bzw. deaktivieren. Die Funktion kannst Du einfach an dieser Stelle aufrufen. If anzahl_messwerteString = row Then funktion_von_cmdStopMonitor end If Aktiviert wird der Button mit cmdStopMonitor.Value = True Also unter Vorbehalt. Ungetestet aus der Erinnerung. Grüße Andreas
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.