Hi experts,
I'm currently trying to create an userform, which is supposed to have the following carateristics - I haven't yet succed in creating this in a perfect way. Let me explain:
What I have created (followed by the code)
- I have a commandbutton, that when entered opens the userform (userform 1).
-The userform is designed, so that the user starts whit choising from a listbox in the top among several predefinied companies, that are stated in sheet 3 column A.
- For each of the selected companies the user is afterwards supposed to answer several questions.
- In sheet 2, the answers is saved when the "submbit" command button is pushed
Code:
Option Explicit
Private Sub cmbyear_Change()
End Sub
Private Sub UserForm_Initialize()
Dim list As Range
Dim ws As Worksheet
Set ws = Worksheets(3)
'Empty Emp ID Text box and Set the Cursor
txttin.Value = ""
txttin.SetFocus
'Empty all other text box fields
txtloan.Value = ""
txtother.Value = ""
txtcash.Value = ""
For Each list In ws.Range("a2:a20")
With Me.selskabsList
.AddItem list.Value
End With
Next list
'Reset Radio Buttons. Set it to False when form loads.
skatradioyes.Value = False
skatradiono.Value = False
compradioyes.Value = False
compradiono.Value = False
'Reset check Buttons. Set it to False when form loads.
interpaycheck.Value = False
Incomecheck.Value = False
DivCheck.Value = False
cashcheck.Value = False
OpCFcheck.Value = False
loancheck.Value = False
Othercheck.Value = False
End Sub
Private Sub btnsubmit_Click()
Dim emptyRow As Long
'Make Sheet1 active
Sheet2.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = selskabsList.Value
'Skat
If skatradioyes.Value = True Then
Cells(emptyRow, 2).Value = "Yes"
Else
Cells(emptyRow, 2).Value = "No"
End If
Cells(emptyRow, 3).Value = txttin.Value
'Source of funds
If interpaycheck.Value = True Then
Cells(emptyRow, 4).Value = "Yes"
Else
Cells(emptyRow, 4).Value = "No"
End If
If OpCFcheck.Value = True Then
Cells(emptyRow, 5).Value = "Yes"
Else
Cells(emptyRow, 5).Value = "No"
End If
If DivCheck.Value = True Then
Cells(emptyRow, 6).Value = "Yes"
Else
Cells(emptyRow, 6).Value = "No"
End If
If Incomecheck.Value = True Then
Cells(emptyRow, 7).Value = "Yes"
Else
Cells(emptyRow, 7).Value = "No"
End If
If cashcheck.Value = True Then
Cells(emptyRow, 8).Value = "Yes"
Else
Cells(emptyRow, 8).Value = "No"
End If
Cells(emptyRow, 9).Value = txtcash.Value
If loancheck.Value = True Then
Cells(emptyRow, 10).Value = "Yes"
Else
Cells(emptyRow, 10).Value = "No"
End If
Cells(emptyRow, 11).Value = txtloan.Value
If Othercheck.Value = True Then
Cells(emptyRow, 12).Value = "Yes"
Else
Cells(emptyRow, 12).Value = "No"
End If
Cells(emptyRow, 13).Value = txtother.Value
If compradioyes.Value = True Then
Cells(emptyRow, 14).Value = "Yes"
Else
Cells(emptyRow, 14).Value = "No"
End If
Sheet1.Activate
End Sub
Private Sub btncancel_Click()
Unload Me
End Sub
What I need to add
- Currently, the data from e.g company 1 is only saved in sheet 2, when you enter submit. Afterwards, when you then choise company 2, it is not possible to go back to company 1 and see or edit what you have entered. Is there a code for this. I can send my excelsheet pr mai?
Really hope you guys can help me.
Best regards
Kevin
I'm currently trying to create an userform, which is supposed to have the following carateristics - I haven't yet succed in creating this in a perfect way. Let me explain:
What I have created (followed by the code)
- I have a commandbutton, that when entered opens the userform (userform 1).
-The userform is designed, so that the user starts whit choising from a listbox in the top among several predefinied companies, that are stated in sheet 3 column A.
- For each of the selected companies the user is afterwards supposed to answer several questions.
- In sheet 2, the answers is saved when the "submbit" command button is pushed
Code:
Option Explicit
Private Sub cmbyear_Change()
End Sub
Private Sub UserForm_Initialize()
Dim list As Range
Dim ws As Worksheet
Set ws = Worksheets(3)
'Empty Emp ID Text box and Set the Cursor
txttin.Value = ""
txttin.SetFocus
'Empty all other text box fields
txtloan.Value = ""
txtother.Value = ""
txtcash.Value = ""
For Each list In ws.Range("a2:a20")
With Me.selskabsList
.AddItem list.Value
End With
Next list
'Reset Radio Buttons. Set it to False when form loads.
skatradioyes.Value = False
skatradiono.Value = False
compradioyes.Value = False
compradiono.Value = False
'Reset check Buttons. Set it to False when form loads.
interpaycheck.Value = False
Incomecheck.Value = False
DivCheck.Value = False
cashcheck.Value = False
OpCFcheck.Value = False
loancheck.Value = False
Othercheck.Value = False
End Sub
Private Sub btnsubmit_Click()
Dim emptyRow As Long
'Make Sheet1 active
Sheet2.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = selskabsList.Value
'Skat
If skatradioyes.Value = True Then
Cells(emptyRow, 2).Value = "Yes"
Else
Cells(emptyRow, 2).Value = "No"
End If
Cells(emptyRow, 3).Value = txttin.Value
'Source of funds
If interpaycheck.Value = True Then
Cells(emptyRow, 4).Value = "Yes"
Else
Cells(emptyRow, 4).Value = "No"
End If
If OpCFcheck.Value = True Then
Cells(emptyRow, 5).Value = "Yes"
Else
Cells(emptyRow, 5).Value = "No"
End If
If DivCheck.Value = True Then
Cells(emptyRow, 6).Value = "Yes"
Else
Cells(emptyRow, 6).Value = "No"
End If
If Incomecheck.Value = True Then
Cells(emptyRow, 7).Value = "Yes"
Else
Cells(emptyRow, 7).Value = "No"
End If
If cashcheck.Value = True Then
Cells(emptyRow, 8).Value = "Yes"
Else
Cells(emptyRow, 8).Value = "No"
End If
Cells(emptyRow, 9).Value = txtcash.Value
If loancheck.Value = True Then
Cells(emptyRow, 10).Value = "Yes"
Else
Cells(emptyRow, 10).Value = "No"
End If
Cells(emptyRow, 11).Value = txtloan.Value
If Othercheck.Value = True Then
Cells(emptyRow, 12).Value = "Yes"
Else
Cells(emptyRow, 12).Value = "No"
End If
Cells(emptyRow, 13).Value = txtother.Value
If compradioyes.Value = True Then
Cells(emptyRow, 14).Value = "Yes"
Else
Cells(emptyRow, 14).Value = "No"
End If
Sheet1.Activate
End Sub
Private Sub btncancel_Click()
Unload Me
End Sub
What I need to add
- Currently, the data from e.g company 1 is only saved in sheet 2, when you enter submit. Afterwards, when you then choise company 2, it is not possible to go back to company 1 and see or edit what you have entered. Is there a code for this. I can send my excelsheet pr mai?
Really hope you guys can help me.
Best regards
Kevin