Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
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.
Private Sub NieuweInvoerOpslaan_Click()
Dim lRow As Long
'Vind de eerste lege rij in uw database
lRow = Sheets("Blad1").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
'copy the data to the database
With Sheets("Blad1")
.Cells(lRow, 1) = Me.ComboBox1.Value
For i = 2 To 5
If InStr("|2|3|4|", "|" & i & "|") Then
Me("TextBox" & i).Value = Replace(Me("TextBox" & i).Value, ",", ".")
If Not IsNumeric(Me("TextBox" & i).Value) Then
MsgBox "Er wordt een numerieke waarde verwacht bij textbox " & i & "."
Me("TextBox" & i).SetFocus
Exit Sub
Exit For
End If
End If
.Cells(lRow, i) = Me("TextBox" & i).Value
Next
End With
'clear the data
Me.ComboBox1.Value = ""
For i = 2 To 5
Me("TextBox" & i).Text = ""
Next
Me.ComboBox1.SetFocus
End Sub
Hier een voorbeeld om bij een aantal textboxen verplicht een getal in te voeren.
geef tussen "|" (shift + toets boven enter) de getallen van de textboxen aan die numeriek moeten zijn.
tevens wordt , door . vervangen.
PS voor wijzigen van data moet je de macro nog wel hetzelfde maken als voor opslaan.
Private Sub WijzigenEnOpslaan_Click()
With Worksheets("Blad1")
waarde = Me.ComboBox1.Value
.Cells(code, 1) = waarde
For i = 2 To 5
If InStr("|2|3|4|", "|" & i & "|") Then
Me("TextBox" & i).Value = Replace(Me("TextBox" & i).Value, ",", ".")
If Not IsNumeric(Me("TextBox" & i).Value) Then
MsgBox "Er wordt een numerieke waarde verwacht bij textbox " & i & "."
Me("TextBox" & i).SetFocus
Exit Sub
Exit For
End If
End If
.Cells(code, i) = Me("TextBox" & i).Value
Next
End With
End Sub
Sub Kaart()
Medewerkerskaart.Show
End Sub
Function LastUsedRow(Optional wks As Worksheet) As Long
' Visible or hidden, filtered or not
Dim iFilt As Long
Dim iFind As Long
With IIf(wks Is Nothing, ActiveSheet, wks)
If WorksheetFunction.CountA(.UsedRange) = 0 Then Exit Function
If .FilterMode Then iFilt = .AutoFilter.Range.Row + .AutoFilter.Range.Rows.Count - 1
iFind = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
End With
LastUsedRow = IIf(iFind > iFilt, iFind, iFilt)
End Function
Dim code As Integer
Private Sub ComboBox1_Change()
On Error Resume Next
code = Worksheets("Gegevens").Range("A:AH").Find(ComboBox1.Value, LookIn:=xlFormulas, Lookat:=xlWhole).Row
End Sub
Private Sub UserForm_Initialize()
With Sheets("Gegevens")
sq = .Range("A3:A" & .Cells(Rows.Count, 1).End(xlUp).Row)
End With
For lLoop = 1 To UBound(sq)
For lLoop2 = lLoop To UBound(sq)
If UCase(sq(lLoop2, 1)) < UCase(sq(lLoop, 1)) Then
str1 = sq(lLoop, 1)
str2 = sq(lLoop2, 1)
sq(lLoop, 1) = str2
sq(lLoop2, 1) = str1
End If
Next lLoop2
Next lLoop
ComboBox1.List = sq
End Sub
Private Sub NieuweInvoerOpslaan_Click()
Dim lRow As Long
'Vind de eerste lege rij in uw database
lRow = Sheets("Gegevens").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
'copy the data to the database
With Sheets("Gegevens")
.Cells(lRow, 1) = Me.ComboBox1.Value
For i = 2 To 34
If InStr("|14|15|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|", "|" & i & "|") Then
Me("TextBox" & i).Value = Replace(Me("TextBox" & i).Value, ",", ".")
If Not IsNumeric(Me("TextBox" & i).Value) And Me("TextBox" & i).Value <> "" Then
MsgBox "Er wordt een numerieke waarde verwacht bij textbox " & i & "."
Me("TextBox" & i).SetFocus
Exit Sub
Exit For
End If
End If
.Cells(lRow, i) = Me("TextBox" & i).Value
Next
End With
'clear the data
Me.ComboBox1.Value = ""
For i = 2 To 34
Me("TextBox" & i).Text = ""
Next
Me.ComboBox1.SetFocus
End Sub
Private Sub WijzigenEnOpslaan_Click()
With Worksheets("Gegevens")
waarde = Me.ComboBox1.Value
.Cells(code, 1) = waarde
For i = 2 To 34
If InStr("|14|15|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|", "|" & i & "|") Then
Me("TextBox" & i).Value = Replace(Me("TextBox" & i).Value, ",", ".")
If Not IsNumeric(Me("TextBox" & i).Value) And Me("TextBox" & i).Value <> "" Then
MsgBox "Er wordt een numerieke waarde verwacht bij textbox " & i & "."
Me("TextBox" & i).SetFocus
Exit Sub
Exit For
End If
End If
.Cells(code, i) = Me("TextBox" & i).Value
Next
End With
'clear the data
Me.ComboBox1.Value = ""
For i = 2 To 34
Me("TextBox" & i).Value = ""
Next
Me.ComboBox1.SetFocus
End Sub
Private Sub Opzoeken_Click()
With Worksheets("Gegevens")
For i = 2 To 34
Me("TextBox" & i) = .Cells(code, i)
Next
End With
End Sub
Private Sub TextBox7_Change()
TextBox7.Value = Format(TextBox7.Text, "dd-mm-yyyy")
End Sub
Private Sub TextBox10_Change()
TextBox10.Value = Format(TextBox10.Text, "dd-mm-yyyy")
End Sub
Private Sub TextBox11_Change()
TextBox11.Value = Format(TextBox11.Text, "dd-mm-yyyy")
End Sub
Private Sub TextBox12_Change()
TextBox12.Value = Format(TextBox12.Text, "dd-mm-yyyy")
End Sub
Private Sub MedewerkersZichtbaar_Click()
Application.ScreenUpdating = False
Rows.Hidden = False
Range("A1").Select
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub MedewerkersVerbergen_Click()
Application.ScreenUpdating = False
Dim rij As Integer
For rij = 1 To Range("a65500").End(xlUp).Row
If Cells(rij, 1).Font.Color = vbRed Then
Rows(rij).Hidden = True
End If
Next
Range("A1").Select
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub GaNaarDezeWeek_Click()
Application.ScreenUpdating = False
Columns("A:XFD").Hidden = False
With Sheets("Gegevens")
i = WorksheetFunction.Match(CLng(Date), .Rows(2), 0)
Application.Goto .Cells(1, i), True
End With
Range("A1").Select
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub Sorteren_Click()
Application.ScreenUpdating = False
ActiveWorkbook.Worksheets("Gegevens").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Gegevens").Sort.SortFields.Add Key:=Range("O3:O500" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Gegevens").Sort.SortFields.Add Key:=Range("A3:A500" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Gegevens").Sort
.SetRange Range("A3:ACS500")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub AllesZichtbaar_Click()
Application.ScreenUpdating = False
Columns("A:XFD").Hidden = False
Range("C3").Select
ActiveWindow.FreezePanes = True
SendKeys ("^{HOME}")
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub AlleVeldenLeegmaken_Click()
'clear the data
Me.ComboBox1.Value = ""
For i = 2 To 34
Me("TextBox" & i).Text = ""
Next
Me.ComboBox1.SetFocus
End Sub
Private Sub Opzoeken_Click()
If ComboBox1.ListIndex = -1 Then Exit Sub
With Worksheets("Blad1")
For i = 2 To 5
Me("TextBox" & i) = .Cells(code, i)
Next
End With
End Sub
Private Sub NieuweInvoerOpslaan_Click()
Dim lRow As Long
'Vind de eerste lege rij in uw database
lRow = LastUsedRow() 'dit is aangepast
'copy the data to the database
With Sheets("Gegevens")
enz.....
Private Sub NieuweInvoerOpslaan_Click()
Dim lRow As Long
'Vind de eerste lege rij in uw database
[COLOR="#FF0000"]lRow = LastUsedRow() +1[/COLOR]
'copy the data to the database
With Sheets("Gegevens")
enz.....
With ActiveWorkbook.Worksheets("Blad1").Sort
.SortFields.Clear
.SortFields.Add Key:=Range("O2:O" & lrow - 1), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("A2:A" & lrow - 1), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange Range("A2:O" & lrow - 1) 'deze aanpassen aan jouw bereik
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
.SetRange Range("A2:O" & lrow - 1) 'deze aanpassen aan jouw bereik
Private Sub TextBox7_Change()
TextBox7.Value = Format(TextBox7.Text, "dd-mm-yyyy")
End Sub
cells(lrow,"??").value=Cdate(TextBox7.value)
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.