Hi all,
I'm new to the forum so please be gentle.
I am trying to create a Userform for my mountaineering logbook that will speed up data entry. I have created the form which has a series of btn selecting the activity. These, in turn, specify which fields should be open for data entry. I then have an 'add entry' button which should write the data to a worksheet, again depending on the activity. However, I can't get the 'add entry' button to work.
I've pasted the code below for reference. The problems I have are getting the data to write to different sheets depending on the acitivity selected and getting it to write at all!
Any help would be much appreciated.
Thanks
Private Sub btnadd_Click()
Dim rowcount As Long
Dim shtname As String
If btnalpmount = True Then shtname = "shtalpmount"
Else: If btnclimb = True Then shtname = "shtclimb"
Else: If btnclimsup = True Then shtname = "shtclimbsup"
Else: If btnsummount = True Then shtname = "shtsummount"
Else: If btnski = True Then shtname = "shtski"
Else: If btnwintmount = True Then shtname = "shtwintmount"
End If
rowcount = Worksheets(shtname).Range("A1").CurrentRegion.Rows.Count
With Worksheets(shtname).Range("A1")
.Offset(rowcount, 0).Value = Me.txtdate.Text
.Offset(rowcount, 1).Value = Me.txtlocation.Text
If Liststatus.Visible = True Then
.Offset(rowcount, 2).Value = Me.txtstatus.Text
Else: .Offset(rowcount, 2).Value = Me.Txtgrade.Text
End If
.Offset(rowcount, 3).Value = Me.txtremarks.Text
If txtQMD.Visible = True Then
.Offset(rowcount, 4).Value = Me.txtQMD.Text
Else: .Offset(rowcount, 4).Value = Me.txtpitches.Text
End If
If txtwildcamp.Visible = True Then
.Offset(rowcount, 5).Value = Me.txtwildcamp.Text
Else: .Offset(rowcount, 5).Value = ""
End If
End With
End Sub
Private Sub btnalpmount_Click()
If btnalpmount = True Then
txtQMD.Visible = True
txtwildcamp.Visible = False
Txtgrade.Visible = False
txtstatus.Visible = True
txtpitches.Visible = False
End If
End Sub
Private Sub btnclimb_Click()
If btnclimb = True Then
txtQMD.Visible = False
txtwildcamp.Visible = False
Txtgrade.Visible = True
txtstatus.Visible = True
txtpitches.Visible = True
End If
End Sub
Private Sub btnclimbsup_Click()
If btnclimbsup = True Then
txtQMD.Visible = False
txtwildcamp.Visible = False
Txtgrade.Visible = False
txtstatus.Visible = True
txtpitches.Visible = False
End If
End Sub
Private Sub btnski_Click()
If btnski = True Then
txtQMD.Visible = True
txtwildcamp.Visible = False
Txtgrade.Visible = False
txtstatus.Visible = True
txtpitches.Visible = False
End If
End Sub
Private Sub btnsummount_Click()
If btnsummount = True Then
txtQMD.Visible = True
txtwildcamp.Visible = True
Txtgrade.Visible = False
txtstatus.Visible = True
txtpitches.Visible = False
End If
End Sub
Private Sub btnview_Click()
Unload Me
End Sub
Private Sub btnwintmount_Click()
If btnwintmount = True Then
txtQMD.Visible = True
txtwildcamp.Visible = True
Txtgrade.Visible = False
txtstatus.Visible = True
txtpitches.Visible = False
End If
End Sub
Private Sub Label7_Click()
End Sub
Bookmarks