Excel VBA: Replace values in Listobject

I am importing some data with a MS QUERY from another workbook and the data is put into a table called CUSTOMERS.

The listobject has several columns and one of them is "First Order Date".
There is one value that I want to remove (not hide with a cell format): 00.01.1900  00:00:00

Is there a neat way to delete this value in the entire listobject with VBA?
I do not mind if the data is converted to a string if that makes it easier and the cell is empty

Thanks

Massimo
Massimo ScolaInternshipAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

pls try
Sub Macro1()
Application.ScreenUpdating = False
For Each c In Range("Table1[First Order Date]")
    If c.Value = 0 Then
        c.ClearContents
    End If
Next
Application.ScreenUpdating = True
End Sub

Open in new window

Regards
0
ShumsDistinguished Expert - 2017Commented:
Hi,

Try below:
Sub DeleteRows_Table()
Dim Ws As Worksheet
Dim j As Long
Application.ScreenUpdating = False
Set Ws = ActiveSheet
With Ws.ListObjects("CUSTOMERS")
    For j = .ListRows.Count To 1 Step -1
        If .ListRows(j).Range(1, .ListColumns("First Order Date").Index) = "00.01.1900  00:00:00" Then
        .ListRows(j).Delete
        End If
    Next j
End With
Application.ScreenUpdating = True
End Sub

Open in new window

0
Rgonzo1971Commented:
corrected code if the Table is customers
Sub Macro1()
Application.ScreenUpdating = False
For Each c In Range("Customers[First Order Date]")
    If c.Value = 0 Then
        c.ClearContents
    End If
Next
Application.ScreenUpdating = True
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Massimo ScolaInternshipAuthor Commented:
Thanks guys ..the codes work like a charm.
0
ShumsDistinguished Expert - 2017Commented:
You're Welcome Massimo! We're glad we're able to help
0
Massimo ScolaInternshipAuthor Commented:
I do have one more follow up question though ..

What if I want to apply this code to every column of the listobject?
How would you amend the code?
0
ShumsDistinguished Expert - 2017Commented:
Do you want answer here or you gonna raise a new question?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.