+ Reply to Thread
Results 1 to 3 of 3

If statement to check if multiple entries exist

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-20-2017
    Location
    Indiana
    MS-Off Ver
    2016
    Posts
    101

    If statement to check if multiple entries exist

    I need to filter a column removing blank entries, then select the cell(s) left. I used the code below to select the cells with multiple entries left, the problem is that when I only have one entry, the macro ctrl+shifts down with no end cell. I'm not sure If I Need some kind of count variable or just an if statement, but any help is appreciated.

    'Filter Column C
        Columns("C:C").Select
        Selection.AutoFilter
    'Filter for Blanks
        ActiveSheet.Range("$C$1:$C$36").AutoFilter Field:=1, Criteria1:="<>"
    'Highlight Cell(s) Orange and make text white
    'Range subject to change
        Range("C8").Select '(first entry)
        Range(Selection, Selection.End(xlDown)).Select '<--- problem

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: If statement to check if multiple entries exist

    First see what the last visible row is before you "select".

    Dim LastRow as Long
    
    
        Columns("C:C").AutoFilter Field:=1, Criteria1:="<>"
        LastRow = Cells(Rows.Count, 3).End(xlUp).Row
        If LastRow > 8 Then 
            Range("C8:C" & LastRow).Select 
        Else
            'Do something else here because lastrow is less than row 8.
        End If
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    02-20-2017
    Location
    Indiana
    MS-Off Ver
    2016
    Posts
    101

    Re: If statement to check if multiple entries exist

    Yep, that worked perfect. Thanks.

+ 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. [SOLVED] Formula that can check for two criteria per customer when multiple customer lines exist
    By Macey351 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-05-2016, 10:11 AM
  2. [SOLVED] help with IF with multiple IF criteria and an ISBLANK check statement
    By rnomis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-24-2016, 10:18 PM
  3. [SOLVED] Check First IF Sheet Is Exist With The Name Of Cell K7 If exist Then run the code
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-18-2015, 10:08 AM
  4. [SOLVED] If statement to check multiple cells for value combinations
    By Joe.lel in forum Excel General
    Replies: 3
    Last Post: 07-09-2012, 10:47 AM
  5. Check range if multiple names exist then show msgbox
    By c.pedersen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2012, 06:23 AM
  6. Replies: 1
    Last Post: 08-14-2010, 10:33 PM
  7. If statement to check multiple criteria
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2009, 11:47 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