Dears,
I would like to kindly ask you for your help regards VBA code.
Issue: I'm having very simple data entry form (kind of attendance list / evidence). I need to upgrade this code - currently data inserted to form are stored in different sheet of same excel file.
I need to also save entered data in another excel file - on shared drive...
I believe for someone very easy (I'm beginner with VBA)
This is complete code I have currently...
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub CommandButton1_Click()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
Dim n As Long
Unload Me
n = sh.Range("A" & Application.Rows.Count).End(xlUp).Row
sh.Range("A" & n + 1).Value = Me.ComboBox2.Value
sh.Range("B" & n + 1).Value = Me.ComboBox3.Value
sh.Range("C" & n + 1).Value = Format(Now(), "dd.mm.yyyy")
sh.Range("d" & n + 1).Value = Format(Now(), "hh:mm")
sh.Range("E" & n + 1).Value = Me.TextBox1.Value
End Sub
Private Sub UserForm_Activate()
With Me.ComboBox2
.Clear
.AddItem ""
.AddItem "Z0001"
.AddItem "Z0002"
.AddItem "Z0003"
End With
With Me.ComboBox3
.Clear
.AddItem ""
.AddItem "Pøíchod do práce"
.AddItem "Odchod z práce"
End With
End Sub
Thanks for your help in advance...
Radek
I would like to kindly ask you for your help regards VBA code.
Issue: I'm having very simple data entry form (kind of attendance list / evidence). I need to upgrade this code - currently data inserted to form are stored in different sheet of same excel file.
I need to also save entered data in another excel file - on shared drive...
I believe for someone very easy (I'm beginner with VBA)
This is complete code I have currently...
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub CommandButton1_Click()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
Dim n As Long
Unload Me
n = sh.Range("A" & Application.Rows.Count).End(xlUp).Row
sh.Range("A" & n + 1).Value = Me.ComboBox2.Value
sh.Range("B" & n + 1).Value = Me.ComboBox3.Value
sh.Range("C" & n + 1).Value = Format(Now(), "dd.mm.yyyy")
sh.Range("d" & n + 1).Value = Format(Now(), "hh:mm")
sh.Range("E" & n + 1).Value = Me.TextBox1.Value
End Sub
Private Sub UserForm_Activate()
With Me.ComboBox2
.Clear
.AddItem ""
.AddItem "Z0001"
.AddItem "Z0002"
.AddItem "Z0003"
End With
With Me.ComboBox3
.Clear
.AddItem ""
.AddItem "Pøíchod do práce"
.AddItem "Odchod z práce"
End With
End Sub
Thanks for your help in advance...
Radek