Delete cells with content that don't contain the£ symbol

G

Gary N

I have a very large messy excel file that contains some data I want to isolate. The other data is unneeded and basically in the way.

I want to delete/clear all the other cells that do not contain the ? pound symbol. This way I will be left with just the pricing info I need.

All help appreciated
 
R

Ron Rosenfeld

I want to delete/clear all the other cells that do not contain the ? pound symbol.

"Be careful what you wish for"

This can be done with a VBA Macro:

To enter this Macro (Sub), <alt-F11> opens the Visual Basic Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.

To use this Macro (Sub), <alt-F8> opens the macro dialog box. Select the macro by name, and <RUN>.
It will clear every cell that does not contain the £ sign in either the text string or the numberformat string.

The caveat is that, as you requested, ALL cells that do not contain the £ will be cleared. You will find that any cells that have labels, or descriptive data, but do not contain the £ sign, will also be cleared.
Is this what you want?
If not, and if the cells you wish to process are, for example, numbers not formatted with the £ sign, please be more specific about your data. If some of that data you wish to retain is text containing the £ sign, the algorithm will be different than if the data to be retained is numeric data formatted with the £ sign.

===================================================
Option Explicit
Sub ClearPoundData()
Dim rg As Range, c As Range
Const sPound As String = "£"
Set rg = ActiveSheet.UsedRange
For Each c In rg
If InStr(c.Text, sPound) = 0 And _
InStr(c.NumberFormat, sPound) = 0 Then
c.Clear
End If
Next c
End Sub
===========================
 
G

Gary N

Wow your solution was perfect, exactly what I needed, you are a real lifesaver and I SO much appreciate this! My sincere THANKS :)
 
R

Ron Rosenfeld

Wow your solution was perfect, exactly what I needed, you are a real lifesaver and I SO much appreciate this! My sincere THANKS :)

Glad to help. Thanks for the feedback.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top