Excel/VBA Edit/view data in userform

Kevin12

New Member
Joined
Dec 9, 2015
Messages
4
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
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi,
it is possible to do what you ask but would be helpful to those who can offer assistance, if you can place copy of your workbook in a dropbox & provide a link to it here.


Dave
 
Upvote 0
Hi

Good idea Dave. Though, in the mean time I guess I have figured it out. I will upload a new thread with a new headline that is more suitable for the specific question. Thank you Dave for answering!

Kevin
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top