Passing data to next empty row

tigerdel

Board Regular
Joined
Oct 13, 2015
Messages
145
Office Version
  1. 365
Platform
  1. Windows
The code below shows no errors but does not post any data when I click the button

Code:
Private Sub cmbAddEntry_Click()
Dim LastRow As Long, ws As Worksheet
Set ws = ActiveSheet
LastRow = ws.Range("a" & Rows.Count).End(xlUp).Row + 1
    ws.Range("B" & LastRow) = txtDate.Text
    ws.Range("G" & LastRow) = cmbVAT.value
    ws.Range("H" & LastRow) = txtValue.value
    ws.Range("C" & LastRow) = cmbSuppliers.value
    If cmbColumn.value = "Stock" Then
    ws.Range("I" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Motor Expenses" Then
    ws.Range("J" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Rent" Then
    ws.Range("K" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Utilities" Then
    ws.Range("L" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Telecoms" Then
    ws.Range("M" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Printing & Stationery" Then
    ws.Range("N" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Adverts & Promotions" Then
    ws.Range("O" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Insurance" Then
    ws.Range("P" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Sundry Expenses" Then
    ws.Range("Q" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Private Drawings" Then
    ws.Range("R" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Packaging Postage PO Parcel Force" Then
    ws.Range("S" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Banking Fees" Then
    ws.Range("T" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Loans" Then
    ws.Range("U" & LastRow) = txtNett.value
    Else
    If cmbColumn.value = "Wages" Then
    ws.Range("V" & LastRow) = txtNett.value
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub

I'm sure that one of you experts out there will immediately see the error I have obviously made

Cheers all and HAPPY NEW YEAR

Derek
 
What is the formula in col A?
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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