Results 1 to 7 of 7

For Next Loop with IF statement inside does not loop

Threaded View

roxybethany For Next Loop with IF... 08-08-2013, 07:59 PM
Solus Rankin Re: For Next Loop with IF... 08-08-2013, 09:27 PM
protonLeah Re: For Next Loop with IF... 08-08-2013, 09:38 PM
Solus Rankin Re: For Next Loop with IF... 08-08-2013, 09:47 PM
Leith Ross Re: For Next Loop with IF... 08-08-2013, 10:06 PM
roxybethany Re: For Next Loop with IF... 08-09-2013, 11:32 AM
Leith Ross Re: For Next Loop with IF... 08-09-2013, 11:45 AM
  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    12

    Question For Next Loop with IF statement inside does not loop

    I am working on a project (that should be simple) but I cannot get it to work. All I need it to do is to loop through a range of cells that will always start in cell D2 but will have a different ending row count every week and look for any cell that shows #N/A (from a previous vlookup formula) - then show an input box, we input the correct ID# which gets put into the cell instead, and move onto the next cell until there are no more cells. I have tried various ways of doing this and the inputbox part works (i.e. if I have #N/A in the first cell it completes what I want it to do) but it never moves on to the other cells.... please help! Here is my code at the moment (this is just an excerpt so I copied all my variable declarations even what I don't use)...
    Sub Team3Test()
    
    Dim NewSheet As String
    Dim c As Range
    Dim i As Long
    Dim TestRange As Range
    Dim cell As Range
    Dim b As Range
    Dim Employee As String
    Dim SSID As Long
    Dim NumRows As Integer
    Dim myrange As Range
    
    
       Set b = Range("D2")
        NumRows = Range("D2", Range("D2").End(xlDown)).Rows.Count
        Set myrange = Range("D2:D" & NumRows)
        For Each b In myrange
                If Application.IsNA(ActiveCell.Value) Then
                Employee = ActiveCell.Offset(0, -3).Value
                SSID = InputBox("Please enter the Staffsuite ID# for " & Employee & " :", "New Employee Found")
                ActiveCell.Value = SSID
                End If
        Next
        
    End Sub
    Last edited by Leith Ross; 08-08-2013 at 09:22 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Changing the index of a for loop inside of the loop
    By drinkmorewine in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-03-2013, 12:19 PM
  2. [SOLVED] Loop inside a loop problem!
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2012, 12:54 PM
  3. If statement inside a loop
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2011, 06:33 AM
  4. VBA For loop where number of iterations can be changed from inside loop
    By barrboy89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2011, 12:18 PM
  5. Loop inside a Loop
    By jhahes in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-07-2006, 02:23 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