Hi,
I have this VBA which works but i have 2 questions to change/improve
The code is for a userform to transfer data
1. Instead of using the cells.value = Textbox etc..etc.., how would you change this code to use an array formula for transferring the data
2. Instead of sending the data to this workbook how would i change the code so it sends the data to the following network address: \\Smith\public\OPERATIONS\Group\Recording\data\media_Test
3. Cell C4 is the 1st cell which needs to receive data
Also are there other parts of the code which need improving?
Thank you
I have this VBA which works but i have 2 questions to change/improve
The code is for a userform to transfer data
1. Instead of using the cells.value = Textbox etc..etc.., how would you change this code to use an array formula for transferring the data
2. Instead of sending the data to this workbook how would i change the code so it sends the data to the following network address: \\Smith\public\OPERATIONS\Group\Recording\data\media_Test
3. Cell C4 is the 1st cell which needs to receive data
Also are there other parts of the code which need improving?
Thank you
Code:
Private Sub UserForm_Initialize()
Me.Combobox1_Date.RowSource = ""
Me.Combobox1_Date.List = Application.Transpose(Sheets("Lists").Range("E3:E5").Value)
End Sub
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Media_Test")
Dim strDate As String
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check user input
For Each ctl In Me.Controls
If ctl.Tag <> vbNullString And ctl.Enabled Then
If ctl.Value = vbNullString Then MsgBox ctl.Tag: Exit Sub
End If
Next
With ws
' .Unprotect Password:="password"
.Cells(iRow, 2).Value = Me.Combobox1_Date.Value
.Cells(iRow, 3).Value = TextBox1.Value
.Cells(iRow, 4).Value = TextBox2.Value
.Cells(iRow, 5).Value = TextBox3.Value
.Cells(iRow, 6).Value = TextBox4.Value
.Cells(iRow, 7).Value = TextBox5.Value
.Cells(iRow, 8).Value = TextBox6.Value
.Cells(iRow, 9).Value = ComboBox2.Value
.Cells(iRow, 10).Value = TextBox7.Value
.Cells(iRow, 11).Value = TextBox8.Value
End With
'Clear all fields
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = vbNullString
Next
MsgBox "Data Transferred"
End Sub
Private Sub CommandButton2_Click()
TextBox1.Value = Split(Now())(1)
End Sub
Private Sub CommandButton3_Click()
TextBox2.Value = Split(Now())(1)
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If MsgBox("Are you sure you want to close?", vbYesNo) = vbNo Then
Cancel = True
End If
End Sub