• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Userform

Status
Niet open voor verdere reacties.

stefano

Gebruiker
Lid geworden
22 mei 2004
Berichten
865
Ik gebruik voor de eerste keer een userform. Bedoeling van deze form is waarden in te geven vanaf cel c32, vervolgens e32, g32, ... Zie de code hieronder. Wanneer ik de code oproep worden de gegevens ergens op het blad gedeponeerd. Sturen door gebruik van

Code:
ActiveCell.Offset(32, 3).Select

Lukt blijkbaar ook niet. Ik wil dus eerste data ingeven in cel C32 . Bekijk bijlage helpmij.nl.xlsmKan iemand helpen aub?

Dank,

Stefano

Code:
Private Sub CommandButton1_Click()

If TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Or TextBox5.Value = "" Or TextBox6.Value = "" Or TextBox7.Value = "" Or TextBox8.Value = "" Or TextBox9.Value = "" Or TextBox10.Value = "" Then
    If MsgBox("Velden zijn niet ingevuld, wil je verder gaan?", vbQuestion + vbYesNo) <> vbYes Then
    Exit Sub
    End If
End If

ActiveCell = TextBox1.Value
ActiveCell.Offset(0, 1) = TextBox2.Value
ActiveCell.Offset(0, 2) = TextBox3.Value
ActiveCell.Offset(0, 3) = TextBox4.Value
ActiveCell.Offset(0, 4) = TextBox5.Value
ActiveCell.Offset(0, 5) = TextBox6.Value
ActiveCell.Offset(0, 6) = TextBox7.Value
ActiveCell.Offset(0, 7) = TextBox8.Value
ActiveCell.Offset(0, 8) = TextBox9.Value
ActiveCell.Offset(0, 9) = TextBox10.Value
ActiveCell.Offset(32, 3).Select

Call resetform

End Sub
Sub resetform()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""

UserForm1.TextBox1.SetFocus


End Sub
 
Code:
Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Or TextBox5.Value = "" Or TextBox6.Value = "" Or TextBox7.Value = "" Or TextBox8.Value = "" Or TextBox9.Value = "" Or TextBox10.Value = "" Then
    If MsgBox("Velden zijn niet ingevuld, wil je verder gaan?", vbQuestion + vbYesNo) <> vbYes Then
    Exit Sub
    End If
End If

cells(rows.count, 3).end(xlup).offset(1).resize(,10)=array(textbox1,textbox2,textbox3,textbox4,textbox5,textbox6,textbox7,textbox8,textbox9,textbox10)

Call resetform


End Sub
 
twee zaken,

De data worden nu een rij te laag ingevoegd (rij 33 in plaats van rij 32)

Eerste getal komt in kolom C, tweede in D, derde in E, ... in plaats van in

C, E, G, I, ( om de twee kolommen).
 
Code:
 cells(rows.count, 3).end(xlup).offset(1).resize(, 19) =array(textbox1, "", textbox2, "", textbox3, "",textbox4, "", textbox5, "", textbox6, "", textbox7, "", textbox8, "",textbox9, "",textbox10)
 
Of zo:
Code:
Private Sub CommandButton1_Click()
Dim i As Integer

    For i = 1 To 10
        If Me("TextBox" & i).Value = "" Then
            If MsgBox("Velden zijn niet ingevuld, wil je verder gaan?", vbQuestion + vbYesNo) <> vbYes Then Exit Sub
        End If
    Next i
    
    For i = 1 To 10
        ActiveCell.Offset(0, i - 1) = Me("TextBox" & i).Value
    Next i
    ActiveCell.Offset(32, 3).Select
    
    For i = 1 To 10
        Me("TextBox" & i).Value = ""
    Next i

End Sub
 
Dank voor de correctie , maar hoe krijg ik de cijfers dan in rij 32 ?
 
Code:
Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Or TextBox5.Value = "" Or TextBox6.Value = "" Or TextBox7.Value = "" Or TextBox8.Value = "" Or TextBox9.Value = "" Or TextBox10.Value = "" Then
    If MsgBox("Velden zijn niet ingevuld, wil je verder gaan?", vbQuestion + vbYesNo) <> vbYes Then
    Exit Sub
    End If
End If


 For j = 1 To 10
   Me("textbox" & j) = Replace(Me("textbox" & j), ".", ",")
 Next j


 Cells(Rows.Count, 3).End(xlUp).Offset(1).Resize(, 19) = Array(CDbl(TextBox1.Value), "", CDbl(TextBox2.Value), "", CDbl(TextBox3.Value), "", CDbl(TextBox4.Value), "", CDbl(TextBox5.Value), "", CDbl(TextBox6.Value), "", CDbl(TextBox7.Value), "", CDbl(TextBox8.Value), "", CDbl(TextBox9.Value), "", CDbl(TextBox10.Value))


For i = 1 To 10
   Me("TextBox" & i).Value = ""
Next i





End Sub
 
Code:
    For i = 1 To 10
        ActiveCell.Offset(32, i +2) = Me("TextBox" & i).Value
    Next i
    ActiveCell.Offset(32, 3).Select
 
10+2 =12 @Octa, maar dat wist je vast al. :d

Code:
set c = cells(rows.count,3).end(xlup).offset(1)
For i = 0 To 19 step 2
  n =n +1
      c.offset(,i)  = Me("TextBox" & n).Value
    Next i
 
Beste,

dank voor de hulp maar ik weet niet waar ik die private sub nu moet gaan plaatsen. ik probeerde die bij de modules te plakken maar dan kan ik die niet oproepen.

Moet die dan bij het werkblad of zo.
 
In de module van het formulier.
Code:
Private Sub CommandButton1_Click()
If TextBox1.Value = "" Or TextBox2.Value = "" Or TextBox3.Value = "" Or TextBox4.Value = "" Or TextBox5.Value = "" Or TextBox6.Value = "" Or TextBox7.Value = "" Or TextBox8.Value = "" Or TextBox9.Value = "" Or TextBox10.Value = "" Then
    If MsgBox("Velden zijn niet ingevuld, wil je verder gaan?", vbQuestion + vbYesNo) <> vbYes Then
    Exit Sub
    End If
End If
Set c = Cells(Rows.Count, 3).End(xlUp).Offset(1)
For i = 0 To 19 Step 2
  n = n + 1
      c.Offset(, i) = Me("TextBox" & n).Value
    Next i


 For j = 1 To 10
   Me("textbox" & j) = Replace(Me("textbox" & j), ".", ",")
 Next j
  
Cells(Rows.Count, 3).End(xlUp).Offset(1).Resize(, 19) = Array(CDbl(TextBox1.Value), "", CDbl(TextBox2.Value), "", CDbl(TextBox3.Value), "", CDbl(TextBox4.Value), "", CDbl(TextBox5.Value), "", CDbl(TextBox6.Value), "", CDbl(TextBox7.Value), "", CDbl(TextBox8.Value), "", CDbl(TextBox9.Value), "", CDbl(TextBox10.Value))


For j = 1 To 10
   Me("textbox" & j) = ""
 Next j


End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan