Results 1 to 2 of 2

Can't get VBA Userform (mac) to write data to worksheets

Threaded View

  1. #1
    Registered User
    Join Date
    08-25-2012
    Location
    London, England
    MS-Off Ver
    Excel 2011 Mac
    Posts
    1

    Can't get VBA Userform (mac) to write data to worksheets

    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
    Last edited by Cutter; 08-25-2012 at 02:00 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1