Results 1 to 15 of 15

Convert IF(AND) formula to VBA for convenience

Threaded View

  1. #1
    Registered User
    Join Date
    08-13-2017
    Location
    Belfast, Ireland
    MS-Off Ver
    MS 2016
    Posts
    23

    Convert IF(AND) formula to VBA for convenience

    Hi

    I am trying to convert the below formula to a VBA code so I can provide to colleagues to use, as they always seem to mess up the formula when assisting me with reports when I am on leave etc.

    =IF(AND(COUNTIF(b:b,b2)>1,au2="E Data"),"Delete","")

    The formula is entered in Col AV, starting in cell AV2 (as Row 1 contains the headers for each column). Then I am either filtering for the 'Delete' value and deleting rows manually, or using the Ctrl+F in Col AV, 'Look in... Values' and then selecting 'Delete Sheet Rows' from the 'Home>Cells' ribbon (if the formula is left intact, if not, I don't need to change the 'look in' option).

    I have had to explain this to some colleagues several times and they seem to always miss a step and delete the wrong records, or just don't get the formula right. Previous to this formula, I was using conditional formatting to highlight duplicates in Col B and then filter to select these 'by colour'; then in Col AU, filter and select 'E Data' and then delete. However as our reports grow in size (more records = more rows), this takes longer to complete as I keep getting the dreaded 'Not Responding' white screen regardless of working on the workbook on my desktop or straight from shared drives etc.

    Can someone take me through the process of converting it to VBA, or offer an alternative VBA code?

    Conditions:
    (1) It would have to apply to an Active Workbook and Active Sheet as the reports I use it on are generated with different names for each depending on the date etc.
    (2) The report always has Cols A > AU, with Cols B and AU containing the values I am using to remove rows (records created in error by agents).
    (3) There will be an increasing number of rows to search as the reports are cumulative of records created from a certain past date to the current date each time they are run, with several hundred new records created daily.

    Any help is much appreciated. My VBA knowledge is extremely basic, so I'm trying to build it up bit by bit. Unfortunately I can't attach the reports as they contain lots of customer data which would need to be anonymised/removed and would just take too long to do.

    Thanks
    Last edited by liamlarmour; 09-17-2017 at 07:35 AM. Reason: correct typos

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 8
    Last Post: 09-29-2016, 08:21 AM
  2. Convert Cell Formula to Convert Text to VBA Code
    By PY_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2014, 05:51 PM
  3. Replies: 3
    Last Post: 04-24-2014, 05:51 PM
  4. monthly closing report for convenience store
    By omair-ayaz in forum Excel General
    Replies: 3
    Last Post: 06-02-2013, 04:06 PM
  5. Formula as text in cell -> convert to formula result
    By AHFoddeR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-12-2013, 02:00 AM
  6. [SOLVED] Need to Convert Formula R1C1 into A1-style but the Formula String exceeds 255 characters
    By VBA_Gary in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-04-2012, 12:09 PM
  7. Adding http://www. in a cell for convenience
    By TPD in forum Excel General
    Replies: 3
    Last Post: 05-16-2005, 02:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1