Clear Last row with first blank Cell, keeping the formulas

gotido

New Member
Joined
Dec 13, 2017
Messages
41
Office Version
  1. 365
Platform
  1. MacOS
Hello, i have a table where i´m going to put some sales.

A is date; B is Produt and C is value.

I´ve created a button for some specified products when when i click then the value apears in the row.

I want to create another button the delete the last inserted row.

Help appreciated.

This is the code of one of the buttons that i sell

Code:
Sub Button3_Click()

Dim emptycolumn As Long


'Make Sheet1 active
 Sheet2.Activate


'Determine emptycolumn
 emptycolumn = WorksheetFunction.CountA(Range("a:a")) + 1


'Transfer information
 Cells(emptycolumn, 1).Value = Now()
 Cells(emptycolumn, 3).Value = "FLAP JACK OAT & CHOC"
 Cells(emptycolumn, 4).Value = "2,95€"


 Sheet2.Activate


End Sub
 
Last edited:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Your subject Title says:
Clear Last row with first blank Cell, keeping the formulas

But you question says delete last row.





Try this:
Code:
Sub Delete_Me()
'Modified  1/26/2019  3:31:07 AM  EST
Dim Lastrow As Long
Sheet2.Activate
Lastrow = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row
Rows(Lastrow).Delete
End Sub
 
Last edited:
Upvote 0
Its my fault, my bad english.

I´d like to clear the last row without losing the formulas in it. only the values..
 
Upvote 0
You can't clear the cells and have a formula in them. If you want them to display an empty string based on a condition then you need to amend the formula.

If you mean you want to clear the cells that don't have formulas then you could try...

Code:
 Dim Lastrow As Long

Lastrow = Sheet2.Cells(Rows.count, "A").End(xlUp).Row
On Error Resume Next
Sheet2.Rows(Lastrow).SpecialCells(2, 23).ClearContents
On Error Goto 0

Otherwise please try and explain again..
 
Upvote 0

Forum statistics

Threads
1,224,760
Messages
6,180,816
Members
452,996
Latest member
nelsonsix66

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