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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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