Button Fault on Userform

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
204
ARHHHRHR

WHat dit i Wrong in this Macro

on a userform i have 3 button

Button 1 Put "1" into cell C1
Button 2 Put "2" into Cell C1

when i Press On Button 1 or Button 2 The cell was Empty

Button 3 Close Userform

Button 3 works fine but not button 1 and 2

Her is my code



Private Sub CommandButton2_Click()
Dim cl As Range
For Each cl In Range("C1")
cl = ""
Next cl

Range("C1").Select
Range("C1").Value = 2




End Sub

Private Sub CommandButton3_Click()
Unload UserForm1
End




End Sub


Private Sub UserForm_Initialize()
'Modified 10/2/2018 9:31:19 PM EDT
Label1.Caption = Worksheets("Ark1").Range("B1").Value
Label2.Caption = Worksheets("Ark1").Range("B1").Value
End Sub


Private Sub CommandButton1_Click()
Dim cl As Range
For Each cl In Range("C1")
cl = ""
Next cl

Range("C1").Select
Range("C1").Value = 1


End Sub
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
try
Code:
Private Sub CommandButton2_Click()
   Sheets("???").Range("C1").Value = 2
End Sub
 
Upvote 0
some How did i get it to Work By clean cell when i call Userform by Double Click

thanks for your Answer anyway "Fluff"
 
Upvote 0
.
Try (if I understand your question correctly) :


Code:
Option Explicit


Private Sub CommandButton1_Click()
    Sheets("Ark1").Range("C1").Value = "1"
End Sub


Private Sub CommandButton2_Click()
    Sheets("Ark1").Range("C1").Value = "2"
End Sub


Private Sub CommandButton3_Click()
    Unload Me
End Sub


Private Sub UserForm_Click()


End Sub


Private Sub UserForm_Initialize()
    Sheets("Ark1").Range("C1").Value = ""
End Sub
 
Upvote 0
Thanks That works too

even Better than that i finde out by clean cell when i start userform
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,000
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top