+ Reply to Thread
Results 1 to 9 of 9

vba clear contents of range of columns with certain criteria

  1. #1
    Registered User
    Join Date
    01-02-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    48

    vba clear contents of range of columns with certain criteria

    hi

    Just wondering is it possible to clear cells multiple columns based on the criteria instead of column by column.
    For example:
    What i am trying to do i have a file with 28000 lines and want the macro to clear contents of the cells in columns W,X,Z,&AA that contain #N/A.

    Can this be done ? Your wisdom would be great

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba clear contents of range of columns with certain criteria

    Clear the entire column.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-02-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba clear contents of range of columns with certain criteria

    This is what i have, i wanted to delete in the range all together if possible for the cells containing "#n/a"


    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba clear contents of range of columns with certain criteria

    But you said across columns, not a single column which you have is 24. Yes, filter works with a single column.

  5. #5
    Registered User
    Join Date
    01-02-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba clear contents of range of columns with certain criteria

    Sorry for being unclear. This is what i have yes i do it column by column. I was wondering could i do it all in one to speed up my macro?
    So i want to FIND all #n/a in columns W,X,Z,&AA and remove the #n/a leaving the cells blank.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba clear contents of range of columns with certain criteria

    The code does as long as you are clearing an entire column. There is no need to loop, but if you want to clear a single cell, you may need to loop through the cells.

    Could you please attach a sample?

  7. #7
    Registered User
    Join Date
    01-02-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba clear contents of range of columns with certain criteria

    This is what i ended up using. I just did this for every column i needed to clear. Alot of code but works.
    Maybe there is a better solution?

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: vba clear contents of range of columns with certain criteria

    You could have all 4 filters in one code, but need to see and taste a sample book.

  9. #9
    Registered User
    Join Date
    01-02-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba clear contents of range of columns with certain criteria

    Just for info after further research I used the replace function much more efficient thanks for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Clear contents based on criteria
    By Bodz in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-14-2016, 12:13 AM
  2. Clear Cell Contents Based on Criteria
    By AdamsR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2012, 01:52 PM
  3. [SOLVED] Macro to clear contents based on specific criteria
    By greggatz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2012, 10:26 AM
  4. [SOLVED] VBA clear contents except for columns A and B
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 10:26 AM
  5. [SOLVED] Clear Cell Contents Based On Criteria
    By xybadog in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-03-2012, 11:47 AM

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