Deleting query

Uma Chauhan

New Member
Joined
Jul 30, 2019
Messages
7
I want to delete NA from my spreadsheet without getting it deleted from middle of the words like original using vba. Please help
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Welcome to the Board!

Are you wanting to just remove the value, or delete the whole row?

If wanting to just remove the value, you can use Find and Replace, clicking on the Options and making sure that the "Match entire cell contents" check box is selected.

If wanting to delete the whole row, take a look at using Filters.
 
Last edited:
Upvote 0
Hi Joe4,

Thanks for the response, really appreciate it. I am afraid what I am looking for is neither though. I have content in the table with some cells only having NA as content which I am trying to remove but on doing that all the NA occurring in that sheet regardless of being in middle of a word like "Signal" are getting deleted, leaving behind words like Sigl which is complicating my readability. I hop I have clarified the issue. I am using the following code:

Cells.Select
Selection.Replace What:="NA", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp
 
Upvote 0
Yes, that "LookAt" part is exactly the argument that I was talking about (Match entire contents...).
That is just the VBA representation of that Find/Replace. Your code is just that functionality recorded with the Macro Recorder.
So, if you had turned on the Macro Recorder and recorded the step I explained in my first post, you would have gotten the correct version of the code.

Note for future reference, if you have questions about some VBA code you have, it is usually best to post the code in your question, so we can see the exact code you are using.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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