+ Reply to Thread
Results 1 to 8 of 8

Skip line if cell is empty

Hybrid View

Krist2 Skip line if cell is empty 06-30-2015, 12:13 PM
Norie Re: Skip line if cell is empty 06-30-2015, 12:17 PM
Krist2 Re: Skip line if cell is empty 06-30-2015, 01:18 PM
JOHN H. DAVIS Re: Skip line if cell is empty 06-30-2015, 02:11 PM
Norie Re: Skip line if cell is empty 06-30-2015, 02:41 PM
Krist2 Re: Skip line if cell is empty 07-01-2015, 04:55 AM
Krist2 Re: Skip line if cell is empty 07-03-2015, 09:35 AM
Krist2 Re: Skip line if cell is empty 07-03-2015, 09:56 AM
  1. #1
    Registered User
    Join Date
    08-19-2014
    Location
    london, England
    MS-Off Ver
    2011 Mac
    Posts
    5

    Skip line if cell is empty

    Good afternoon folks,

    I'm struggling to find a solution to a problem and was wondering if anyone knew how I would get round this, I'm learning and utilising this forum to the best extent I can but this little step doesn't work for me.

    I have a macro (one I found and changed to my needs), that calls another macro (that I recorded/edited). The Macro is a loop that loops, performs a task, and steps down to perform again.

    Sub UpdateProgress()
    
        Application.ScreenUpdating = True
        
        Call ALL
        
          ' Select cell H10, *first line of data*.
          Range("H10").Select
          ' Set Do loop to stop when an last cell is reached.
          Do Until ActiveCell.FormulaR1C1 = "End"
             ' Insert your code here. Call Macro Needed
             Call CombineUpdates
             ' Step down 1 row from present location.
             ActiveCell.Offset(1, 0).Select
          Loop
          
        Application.ScreenUpdating = True
        
          MsgBox "Update Complete"
        
        
       End Sub
    I think the solution may be something like: if cells(a,1) = "" then goto lastline

    From what I understand it will step down a cell, if it is blank then it will go back a line in my code and not perform the task, stepping down another line and checking if blank and repeating.

    Thanks in advance to anyone that can help!

    Krist

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Skip line if cell is empty

    What do you want to happen when a blank is encountered?

    Do you want the code to end?

    Do you want the sub CombineUpdates not to be called and the code to move on to the next row?

    Something else?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-19-2014
    Location
    london, England
    MS-Off Ver
    2011 Mac
    Posts
    5

    Re: Skip line if cell is empty

    Quote Originally Posted by Norie View Post

    Do you want the sub CombineUpdates not to be called and the code to move on to the next row?
    Exactly this, it skips calling the sub CombineUpdates and moves on to next row to check if that one is empty, if populated it will run, if not it will skip to the next line.


    Sent from my iPhone using Tapatalk

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Skip line if cell is empty

    Maybe:

    Sub Krist2()
    
        Application.ScreenUpdating = True
        
        Call ALL
        
          ' Select cell H10, *first line of data*.
          Range("H10").Select
          ' Set Do loop to stop when an last cell is reached.
          Do Until ActiveCell.FormulaR1C1 = "End"
          If ActiveCell.Value = "" Then GoTo zz
             ' Insert your code here. Call Macro Needed
             Call CombineUpdates
             ' Step down 1 row from present location.
    zz:
             ActiveCell.Offset(1, 0).Select
          Loop
          
        Application.ScreenUpdating = True
        
          MsgBox "Update Complete"
        
        
    
    End Sub

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Skip line if cell is empty

    All you need is an If.
    Sub UpdateProgress()
    
        Application.ScreenUpdating = True
    
        Call ALL
    
        ' Select cell H10, *first line of data*.
        Range("H10").Select
        ' Set Do loop to stop when an last cell is reached.
        Do Until ActiveCell.Value = "End"
            ' Insert your code here. Call Macro Needed
            If ActiveCell.Value <> "" Then
                Call CombineUpdates
            End If
            '  Step down 1 row from present location.
            ActiveCell.Offset(1, 0).Select
        Loop
    
        Application.ScreenUpdating = True
    
        MsgBox "Update Complete"
    
    
    End Sub

  6. #6
    Registered User
    Join Date
    08-19-2014
    Location
    london, England
    MS-Off Ver
    2011 Mac
    Posts
    5

    Re: Skip line if cell is empty

    Quote Originally Posted by Norie View Post
    All you need is an If.
    Sub UpdateProgress()
    
        Application.ScreenUpdating = True
    
        Call ALL
    
        ' Select cell H10, *first line of data*.
        Range("H10").Select
        ' Set Do loop to stop when an last cell is reached.
        Do Until ActiveCell.Value = "End"
            ' Insert your code here. Call Macro Needed
            If ActiveCell.Value <> "" Then
                Call CombineUpdates
            End If
            '  Step down 1 row from present location.
            ActiveCell.Offset(1, 0).Select
        Loop
    
        Application.ScreenUpdating = True
    
        MsgBox "Update Complete"
    
    
    End Sub
    Great, I will try this today and post the results.

    Thanks


    Sent from my iPhone using Tapatalk

  7. #7
    Registered User
    Join Date
    08-19-2014
    Location
    london, England
    MS-Off Ver
    2011 Mac
    Posts
    5

    Re: Skip line if cell is empty

    @Norie works a treat! Perfect thank you.


    Sent from my iPhone using Tapatalk

  8. #8
    Registered User
    Join Date
    08-19-2014
    Location
    london, England
    MS-Off Ver
    2011 Mac
    Posts
    5

    Re: Skip line if cell is empty

    Further to the above guys, I tried to create an active x check box that when checked it will hide all the lines with "yes" in the column.

    It works until it reaches the first "yes" when I step through it. It successfully checks for the yes and skips over if it isn't a "yes", once it comes to the "yes" it has a Runtime Error '424' Object required.

    My code is here:

    Private Sub CheckBox1_Click()
    
    Application.ScreenUpdating = True
    If CheckBox1.Value = True Then
    
        Rows.EntireRow.Hidden = False
    
      
        ' Select cell L10, *first line of data*.
        Range("L10").Select
        ' Set Do loop to stop when an last cell is reached.
        Do Until ActiveCell.Value = "End"
            ' Insert your code here. Call Macro Needed
                If ActiveCell.Value = "Yes" Then
                
                cell.EntireRow.Hidden = True
                
            End If
            '  Step down 1 row from present location.
            ActiveCell.Offset(1, 0).Select
        Loop
    
    Else
    
    Rows.EntireRow.Hidden = False
    
    End If
    
    Application.ScreenUpdating = True
    
    End Sub
    I dont know if will have an effect but I am using a named list for the inputs Yes/No for the column.

    Again, any help would be awesome!

+ 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. Skip empty cell in formula
    By Jeebos in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-01-2014, 03:00 PM
  2. [SOLVED] Need help : Vlookup/index with skip blank/empty cell, problem!!!!
    By Jhon Mustofa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-25-2013, 12:18 AM
  3. [SOLVED] If one cell in line turn empty then entire line turns empty
    By Cristy0505 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-19-2013, 06:02 AM
  4. [SOLVED] Skip/Do not run Macro on the cell if empty/blank
    By Talazem in forum Excel General
    Replies: 3
    Last Post: 11-01-2012, 06:25 PM
  5. Line chart-lot of empty cell
    By missing in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-14-2006, 06:42 AM

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