Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Easy Excel Macro Question

  • 01-09-2010 11:09AM
    #1
    Registered Users, Registered Users 2 Posts: 214 ✭✭


    Hi, I am new to macros and still trying to figure them out, hence the easy question! I have the following macro to delete rows where a certain column is empty. I want to change it to delete if it is empty or 0. See I told you it was easy! Can you use || for or and if so what is the context. Thanks.

    Sub Macro1()
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual 'pre XL97 xlManual
    Dim Rng As Range, ix As Long
    Set Rng = Intersect(Range("N:N"), ActiveSheet.UsedRange)
    For ix = Rng.Count To 1 Step -1
    If Trim(Replace(Rng.Item(ix).Text, Chr(160), Chr(32))) = "" Then
    Rng.Item(ix).EntireRow.Delete
    End If
    Next
    done:
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub


Comments

  • Registered Users, Registered Users 2 Posts: 1,456 ✭✭✭FSL


    You just use OR but you need the complete statement e.g if a=b OR a=c not if a=b OR C (note when typing 'or' it is not case sensitive)


  • Registered Users, Registered Users 2 Posts: 214 ✭✭PinkChick


    Thanks! That worked :-) So obvious now.

    Do you know anything about conditional formatting? I want to make txt bold and red if the cell doesn't say TRUE and is greater than 1. Not working out for me though :-(


Advertisement