Jumat, 13 Juni 2014

[ExcelVBA] Would love feedback on first code

 

If this is incorrect use of this forum, I apologize in advance. I have created a userform for populating data into a spreadsheet, and would love to hear feedback, suggestions, recommendations.

Private Sub cmdTransferStats_Click()

    Dim Pitcher As String
   
    Pitcher = txtPitcher
   
    Worksheets(Pitcher).Activate


    erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
   
'Textbox Input
    Cells(erow, 1) = txtDate.Text
    Cells(erow, 2) = txtOpponent.Text
   
'Option Button Input
    If optYes.Value = True Then
        Cells(erow, 3).Value = 1
    Else
        Cells(erow, 3).Value = 0
    End If
               
'Check Box Input
    If chkWin.Value = True Then
        Cells(erow, 4).Value = 1
    Else
        Cells(erow, 4).Value = 0
    End If
       
    If chkLoss.Value = True Then
        Cells(erow, 5).Value = 1
    Else
        Cells(erow, 5).Value = 0
    End If
   
    If chkTie.Value = True Then
        Cells(erow, 6).Value = 1
    Else
        Cells(erow, 6).Value = 0
    End If

    If chkHeld.Value = True Then
        Cells(erow, 7).Value = 1
    Else
        Cells(erow, 7).Value = 0
    End If

    If chkDecision.Value = True Then
        Cells(erow, 8).Value = 1
    Else
        Cells(erow, 8).Value = 0
    End If

'More Textbox Input
    Cells(erow, 9) = txtIP.Text
    Cells(erow, 10) = txtStrikes.Text
    Cells(erow, 11) = txtBalls.Text
    Cells(erow, 12) = txtER.Text
    Cells(erow, 13) = txtHits.Text
    Cells(erow, 14) = txtBF.Text
    Cells(erow, 15) = txtKs.Text
    Cells(erow, 16) = txtWalks.Text
    Cells(erow, 17) = txtHBP.Text
               
End Sub


__._,_.___

Posted by: jefff@rogers.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar