+ Reply to Thread
Results 1 to 12 of 12

how to avoid infinite loops ine excel vba ?

Hybrid View

meen2525 how to avoid infinite loops... 10-25-2011, 01:39 AM
JapanDave Re: how to avoid infinite... 10-25-2011, 02:06 AM
royUK Re: how to avoid infinite... 10-25-2011, 02:22 AM
meen2525 Re: how to avoid infinite... 10-25-2011, 02:32 AM
meen2525 Re: how to avoid infinite... 10-25-2011, 02:41 AM
royUK Re: how to avoid infinite... 10-25-2011, 02:37 AM
royUK Re: how to avoid infinite... 10-25-2011, 02:51 AM
meen2525 Re: how to avoid infinite... 10-25-2011, 03:02 AM
royUK Re: how to avoid infinite... 10-25-2011, 03:02 AM
meen2525 Re: how to avoid infinite... 10-26-2011, 07:44 AM
royUK Re: how to avoid infinite... 10-26-2011, 07:46 AM
meen2525 Re: how to avoid infinite... 10-26-2011, 07:46 AM
  1. #1
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: how to avoid infinite loops ine excel vba ?

    Something like this
    Option Explicit
    
    Sub IbanNo()
        Dim LR As Long
        Dim iX As Long
        Dim rRng As Range
        LR = ActiveSheet.UsedRange.Rows.Count
    
        For iX = 4 To LR
    
            If Left(Cells(iX, 16), 4) = "PT50" Then
                If rRng Is Nothing Then
                    Set rRng = Cells(iX, 16)
                Else: Set rRng = Union(rRng, Cells(iX, 16))
                End If
            End If
        Next iX
        With rRng
            .Interior.ColorIndex = 3
        End With
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  2. #2
    Registered User
    Join Date
    10-25-2011
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to avoid infinite loops ine excel vba ?

    Hii RoyUk,
    Still a problem but Thanks a lot for replying . The infinite loop has stopped now :D yippee..
    but the problem now is its higlighting the cells which STARTS with PT50. I want it other way round. Highlight the cells NOT STARTIN with PT50. wat to dooo ? plllleaaase help.Thaaaaaanks in advance.

  3. #3
    Registered User
    Join Date
    10-25-2011
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to avoid infinite loops ine excel vba ?

    Hiii,
    I found a way to overcome it.But it colours all other blank cells too . can we JUST color those cells NOT STARTING with PT50 ? any expert advice on this ?? Thaaaaanks in advance

    Please find the code below i modified from yours.

    Code:

    Option Explicit
    
    Sub IbanNo()
        Dim LR As Long
        Dim iX As Long
        Dim rRng As Range
        LR = ActiveSheet.UsedRange.Rows.Count
    
        For iX = 4 To LR
    
            If Left(Cells(iX, 16), 4) <> "PT50" Then
                If rRng Is Nothing Then
                    Set rRng = Cells(iX, 16)
                Else: Set rRng = Union(rRng, Cells(iX, 16))
                End If
            End If
        Next iX
        With rRng
            .Interior.ColorIndex = 3
        End With
    End Sub
    Last edited by meen2525; 10-26-2011 at 07:41 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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