+ Reply to Thread
Results 1 to 12 of 12

Find the column named "Purple" & delete the whole column if there are no blank cells

  1. #1
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Find the column named "Purple" & delete the whole column if there are no blank cells

    Hi all,

    Okay, I'd like a macro that does 3 things..

    1. Find the last row (cell) of data in the "Customer Number" column. This search should be by the name "Customer Number" rather than by column letter because the column that "Customer Number" will be in can change.

    2. Find the column named "Purple" (also by name for same reason)

    3. If the "Purple" column has no blank cells in those same number of rows as the "Customer Number" column, delete the whole "Purple" column.

    Thanks much

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Hello duugg,

    You're full of questions today. Are these column names in row 1?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    LOL,

    Yes

    Thanks

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Hello Duugg,

    This macro finds the columns, and makes the "Purple" column the same size as "Customer Number" column. The "Purple" column is then checked for any blanks. If any blanks are found then the entire column is deleted.
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Leith,

    I got this error

    Compile error:

    Sub or Function not defined

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Hello Duugg,

    It appears I left off a qualifier on the Resize method.
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Sorry Leith,

    I got Runtime error 13 Type mismatch

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Hello Duugg,

    I have had such bad luck answering your posts. Which line has the error?

  9. #9
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Leith,

    Line 25

    Thanks

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Hello Duugg,

    Thanks, found the problem. I used Rng instead of Cell. Here is the corrected and working code...
    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Hi Leith,

    Well, it worked a little too well! What I mean is that it the whole purple column is deleted even when there are blank cells in the purple column that have data in the same row in the "Customer Number" column.

  12. #12
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Re: Find the column named "Purple" & delete the whole column if there are no blank ce

    Bump, no response


    The whole purple column is deleted even when there ARE blank cells in the purple column that have data in the same row in the "Customer Number" column.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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