achugg22
New Member
- Joined
- Jan 18, 2021
- Messages
- 5
- Office Version
- 365
- Platform
- Windows
Hi folks,
I am new to VBA coding and I am in need of some coding help. I am currently working on building a database and have created a UserForm to help input the data I want in quicker. I have got it working for the most part but when I enter the data it keeps going to the bottom of my table rather than the to the next row that is available. The code I have used for the "Add" Button in the UserForm is below. Any help would be appreciated and thanks in advance.
VBA Add Button code:
Private Sub cmdAdd_Click()
'Copy input values to sheet.
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Card Database")
iRow = ws.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
With ws
.Cells(iRow, 3).Value = Me.txtQty.Value
.Cells(iRow, 4).Value = Me.txtCardName.Value
.Cells(iRow, 5).Value = Me.cboCardType.Value
.Cells(iRow, 6).Value = Me.cboRarity.Value
.Cells(iRow, 7).Value = Me.txtSet.Value
.Cells(iRow, 8).Value = Me.txtValue.Value
End With
'Clear input controls.
Me.txtQty.Value = ""
Me.txtCardName.Value = ""
Me.cboCardType.Value = ""
Me.cboRarity.Value = ""
Me.txtSet.Value = ""
Me.txtValue.Value = ""
End Sub
I am new to VBA coding and I am in need of some coding help. I am currently working on building a database and have created a UserForm to help input the data I want in quicker. I have got it working for the most part but when I enter the data it keeps going to the bottom of my table rather than the to the next row that is available. The code I have used for the "Add" Button in the UserForm is below. Any help would be appreciated and thanks in advance.
VBA Add Button code:
Private Sub cmdAdd_Click()
'Copy input values to sheet.
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Card Database")
iRow = ws.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
With ws
.Cells(iRow, 3).Value = Me.txtQty.Value
.Cells(iRow, 4).Value = Me.txtCardName.Value
.Cells(iRow, 5).Value = Me.cboCardType.Value
.Cells(iRow, 6).Value = Me.cboRarity.Value
.Cells(iRow, 7).Value = Me.txtSet.Value
.Cells(iRow, 8).Value = Me.txtValue.Value
End With
'Clear input controls.
Me.txtQty.Value = ""
Me.txtCardName.Value = ""
Me.cboCardType.Value = ""
Me.cboRarity.Value = ""
Me.txtSet.Value = ""
Me.txtValue.Value = ""
End Sub