+ Reply to Thread
Results 1 to 3 of 3

Existing VBA that needs loop adding to the code.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Question Existing VBA that needs loop adding to the code.

    Good Afternoon

    I have the existing code below and it is carrying out its main function (to hilight #N/A errors) and give the user option to correct it, but what I am missing is the abbility for it to move on to the next error once the previous one has been corrected and so on untill there are no more left to correct.

    Heres the code I am using
    Sub FindErrors()
        Dim rError As Range
        On Error Resume Next
        For Each ws In Sheets
            Set rError = Intersect(ws.UsedRange, ws.UsedRange.SpecialCells(xlCellTypeFormulas, 16))
            If Not rError Is Nothing Then
                If MsgBox("Names appear in " & ws.Name & " that have not been added before, Add them them now?", vbYesNo) = vbYes Then
                    ws.Activate
                    rError(1).Activate
                   Exit Sub
                End If
            End If
        Next ws
        
        
    End Sub
    Last edited by arlu1201; 09-06-2012 at 08:16 AM. Reason: Corrected code tags.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Existing VBA that needs loop adding to the code.

    try eliminating exit sub
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Existing VBA that needs loop adding to the code.

    Ah I new it would be something simple, Its been one of those days, However though it just cycles through all of them and doesn't let you change each one individually before it moves on to the next one, It is more than likely an issue with my code as It also checks every tab in the workbook but I want it to check the Raw Data tab only as all the other tabs feed from this one so it is just duplicating itself.

    Thanks again for your quick response.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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