abdullahsikandar

Board Regular
Joined
Feb 10, 2014
Messages
52
Hi Guys,

I need a small help from you guys, I have a excel file where i am importing data from different files. What i need is to delete the whole row when the user write "Done" on the last column called 'AT'.

Like this:

Name ID Status

Abdul 1 Done
Rag 2 Done
Roh 3 Undone
Zai 4 Done

So the result would be like this

Roh 3 Undone.

When we run the macro.

Kindly help me in this matter.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Give this macro a try...

Code:
Sub DeleteDoneInColumnAT()
  Columns("AT").Replace "Done", "#N/A", xlWhole, , False
  Columns("AT").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
End Sub
 
Upvote 0
Hi,

Thanks for your reply.. but still its not working. We already have a "Save" button and what i need when we press that "Save" button it will automatically detect if column 'AT' = "Done" in any column in 'AT', so it will delete that whole row.

Thanks
 
Upvote 0
Hi,

Thanks for your reply.. but still its not working. We already have a "Save" button and what i need when we press that "Save" button it will automatically detect if column 'AT' = "Done" in any column in 'AT', so it will delete that whole row.
So, take the two lines of code from the macro I posted and insert them into the code you are running from your "Save" button at the point in your code when you want to do the deletions. Note, though, that my code does not use a loop... it processes all of Column AT at once... so do not put those two lines of code inside any loops you may have.
 
Upvote 0
Hi,

Thank you so much its working :)... Can you help me little bit more .. If the user write it "Undone" so its fine but if its empty or null so it will pop up the message that kindly fill that 'AT' column first.

Thanks
 
Upvote 0
one more thing if User wrote "Undone" so it will not do anything and if the user remains it null so it will pop up with the message.

Thanks
 
Upvote 0
one more thing if User wrote "Undone" so it will not do anything and if the user remains it null so it will pop up with the message.
Something like this maybe...

Code:
If WorksheetFunction.CountIf(Range("AT1", Cells(Rows.Count, "AT").End(xlUp)), "") Then
  MsgBox "You have blank cells in Column AT... please fill them in"
  Exit Sub
End If
I am not sure about the "Exit Sub" command because I do not know how your "Save" button code is structured, but I am guessing it is what you would want to do. Based on my best guess at what your "Save" button code is probably doing, I am guessing you will want to install this code at the beginning of your existing code.
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,724
Members
449,465
Latest member
TAKLAM

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