+ Reply to Thread
Results 1 to 4 of 4

VBA Choose Another Column If Next is Empty

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    VBA Choose Another Column If Next is Empty

    Hi,

    I am comparing two columns and deleting the unique row if found in any of them. I compare columns A and C. However, sometimes it it possible that column C will be empty so I'd like to choose column D instead to compare with the column A. How can I do that? I tried the if condition but the code gets stuck in the loop. I first compare each row of column C with entire column A and delete unique, then compare each row of Column A with entire Column C and delete the unique if found. Here is the code:

    Please Login or Register  to view this content.
    The objective is to select Column D if the column C is empty, else continue with Column C. I'm stuck on this

    Thanks!

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: VBA Choose Another Column If Next is Empty

    Is the above code working? Then add the elseif condition in this code piece and use D.

    Please Login or Register  to view this content.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,791

    Re: VBA Choose Another Column If Next is Empty

    You could check the value of "Last" something like

    Please Login or Register  to view this content.
    Or you could use CountA i.e
    Please Login or Register  to view this content.
    Alf

  4. #4
    Registered User
    Join Date
    11-27-2012
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: VBA Choose Another Column If Next is Empty

    Thanks arlu1201, the above code works perfectly if I choose a particular column. However, the trouble has been to choose another if C is empty

+ 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