+ Reply to Thread
Results 1 to 4 of 4

How to stop looping if cell A is empty

Hybrid View

  1. #1
    Registered User
    Join Date
    08-19-2015
    Location
    US
    MS-Off Ver
    2010
    Posts
    1

    How to stop looping if cell A is empty

    Hi,
    Would like to know how to stop the looping if cell A is empty.
    Appreciate but i have check out the forums here and nothing seems to work.
    Many thanks in advance

    Sub Fill_Empty()

    Dim oRng As Range
    Set oRng = Selection

    Columns("K:K").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.Font.Bold = False
    Selection.FormulaR1C1 = "=RC[-10]"
    oRng.Copy
    oRng.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False

    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: How to stop looping if cell A is empty

    This is how you add code tags to your post
    Attached Images Attached Images

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: How to stop looping if cell A is empty

    Looking at your code this is what it looks like you are doing.

        Dim oRng As Range, oC As Range
    
        Set oRng = Columns("K:K").SpecialCells(xlCellTypeBlanks)
    
        If Not oRng Is Nothing Then
    
            For Each oC In oRng.Cells
                oC.Value = oC.Offset(, -10).Value
            Next oC
    
        End If
    Your actual question may need more detail, though.

  4. #4
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    Re: How to stop looping if cell A is empty

    probably
        Dim oRng As Range, oC As Range
    
        Set oRng = Columns("K:K").SpecialCells(xlCellTypeBlanks)
    
        If Not oRng Is Nothing Then
    
            For Each oC In oRng.Cells
    If oC.Offset(, -10).Value = "" Then Exit For
    oC.Value = oC.Offset(, -10).Value
            Next oC
    
        End If
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

+ 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] Looping a formula till cell is empty with a button event
    By khhoa in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-09-2015, 02:56 PM
  2. looping to find empty cells and color the offset (0, 1) cell.
    By Neil35 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-07-2015, 02:53 PM
  3. [SOLVED] Looping through cell ranges in multiple worksheets and prevent saving if cell value empty
    By Spritz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-22-2013, 11:24 AM
  4. [SOLVED] Looping till empty cell
    By Alexander_Golinsky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-02-2012, 02:11 PM
  5. Empty Cell Check without Looping
    By TheMan4392000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2011, 11:53 PM
  6. looping through records of left column until cell is empty
    By johnmerlino in forum Excel General
    Replies: 1
    Last Post: 09-23-2010, 04:32 AM
  7. Looping until an empty cell
    By Ricardo9211 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2009, 05:17 PM

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