+ Reply to Thread
Results 1 to 7 of 7

Amend code to do nothing if cells in a range are empty

  1. #1
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Amend code to do nothing if cells in a range are empty

    I have a form that displays a list of items as per the users request and it works very well for me - i just need a little help with the following: The code below hides data in my sheet that the user is not interested in - what I want the code to do though, is IF there is no value in the range specified then do NOTHING. I imagine there needs to be an IF statement in my code below, something along the lines of IF Rng <> "" then ......

    Please Login or Register  to view this content.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Amend code to do nothing if cells in a range are empty

    Instead of looping try it in this way...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Amend code to do nothing if cells in a range are empty

    Sixthsense,
    thanks for the quick reply but that doesnt work, your code doesnt take into account that its looking for the word Company in the range, so your code hides it all?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Amend code to do nothing if cells in a range are empty

    My code just hiding blank cells in your range

  5. #5
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Amend code to do nothing if cells in a range are empty

    hmm, not sure why then but when i use your code it hides everything. I have lots of values in my range 193-250 but they are all hidden.

    Besides, i think even if it did work, it is still ignoring the fact that i want it to hide all rows that dont have the word "Company" in the range.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Amend code to do nothing if cells in a range are empty

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  7. #7
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Amend code to do nothing if cells in a range are empty

    try this

    though i just noticed my SORT HERE button doesnt work in my amended workbook - will look into it but you can see the data I am working with nonetheless
    Attached Files Attached Files

+ 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. Control various cells from one cell - amend existing code
    By SubwAy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2014, 10:00 AM
  2. Replies: 0
    Last Post: 03-20-2014, 11:51 AM
  3. [SOLVED] Amend code to loop over several cells
    By johnlapaz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-15-2013, 11:39 AM
  4. [SOLVED] still have empty cell after run Delete empty cells code
    By tuongtu3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-25-2012, 04:28 PM
  5. Amend code to change range from Col D to a Range
    By Redd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2009, 05:34 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