+ Reply to Thread
Results 1 to 14 of 14

Run Code if Adjacent Cell is not empty

  1. #1
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Run Code if Adjacent Cell is not empty

    Hi Experts,

    I have this code to sort column A:

    Please Login or Register  to view this content.
    need an IF statement so that the the code will run if the adjacent cell in column c is not empty.

    Like if i enter a name in A38 - it will only sort as soon as i'm done entering the data in C38..

    thank you.
    If I've helped U pls click on d *Add Reputation

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Run Code if Adjacent Cell is not empty

    Hello
    Can you attach sample of your workbook? Does your code in worksheet_change event?
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Run Code if Adjacent Cell is not empty

    Yes it is the worksheet_change event..

    The sort will kick in as soon as a Name is entered in Column A..

    Is there a way to postpone it or have it run after data is entered in the adjacent cell in column C?

    Say the name to be added to the sort is entered in A4 - it shouldn't be sorted until data is entered in C4..
    Attached Files Attached Files
    Last edited by bhenlee; 07-06-2018 at 01:55 PM.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Run Code if Adjacent Cell is not empty

    Try this code
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Run Code if Adjacent Cell is not empty

    Hi YasserKhalil,

    Thank you for the code.. it works with the Sample file but i'm not sure why it won't work with my actual data...

    i'm just changing the range to the actual named range in my sheet.

    Any idea?

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Run Code if Adjacent Cell is not empty

    It is better to attach sample of your original file
    I think you have to put the code then save the file .. then close and open again
    Do you encounter any errors?

  7. #7
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Run Code if Adjacent Cell is not empty

    it works fine on my other sheet but im not sure why it won't work on the other file..

    question: could you modify the code so that when a previous data is deleted the sort will still work...

    say the data in row 2 is deleted.. need the remaining data to sort and occupy any empty spaces

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Run Code if Adjacent Cell is not empty

    Can you attach a sample that is similar to your original file?

  9. #9
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Run Code if Adjacent Cell is not empty

    i was able to make it work YasserKhalil.. thanks..

    to my question - could you modify the code so that if a previous data is deleted the sort will still run and rid out any empty rows

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Run Code if Adjacent Cell is not empty

    Can you explain more the second point ..?
    What cells would you clear the contents .. In what column?

  11. #11
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Run Code if Adjacent Cell is not empty

    in the same sheet..

    say if i delete the data in A3:C3... need the the data below it to move up...

    basically there shouldn't be any empty rows within the table

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Run Code if Adjacent Cell is not empty

    Try this version
    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    610

    Re: Run Code if Adjacent Cell is not empty

    thank you, Yasserkhalil

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Run Code if Adjacent Cell is not empty

    You're welcome. Glad I can offer some help
    Please mark the thread as solved

+ 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. Adjacent cell not empty then copy above formula
    By carlrubber in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-15-2016, 10:14 PM
  2. IF statement help. If Adjacent cell is empty then..
    By wizzle89 in forum Excel General
    Replies: 6
    Last Post: 06-15-2015, 02:43 PM
  3. [SOLVED] Automatically lookup and set an empty cell's value if adjacent cell is typed & vice versa
    By RedSummer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-22-2015, 12:16 PM
  4. Do not return a value when adjacent cell in two columns of data is empty
    By randinator in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-03-2014, 01:53 PM
  5. [SOLVED] autofill until adjacent cell empty
    By Hassan1977 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-03-2013, 01:54 PM
  6. Replies: 1
    Last Post: 02-06-2008, 08:23 AM
  7. Finding Adjacent empty cell
    By s1ip in forum Excel General
    Replies: 1
    Last Post: 07-14-2006, 03:55 PM

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