1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Outer loop does not activate

Discussion in 'Business Applications' started by oleslo, Jul 12, 2019.

Thread Status:
Not open for further replies.
  1. oleslo

    oleslo Thread Starter

    Joined:
    Jul 12, 2019
    Messages:
    1
    Hey,

    I'm trying to copy some values from one worksheet to another. The code works fine for the first row, but does not countine to the next ones.

    Here is the code:
    Sub VannprøveResultater()
    i = 3
    j = 3
    Worksheets.Add().Name = "Sheet4"


    Do Until IsEmpty(Worksheets("results").Cells(j, 2))

    Do Until IsEmpty(Worksheets("results").Cells(1, i))
    If InStr(Worksheets("results").Cells(1, i), "Alkalitet") <> 0 Then
    col = 14
    ElseIf InStr(Worksheets("results").Cells(1, i), "Konduktivitet") <> O Then
    col = 11
    ElseIf InStr(Worksheets("results").Cells(1, i), "pH målt ved 23") <> O Then
    col = 10
    ElseIf InStr(Worksheets("results").Cells(1, i), "Kalsium") <> O Then
    col = 20
    ElseIf InStr(Worksheets("results").Cells(1, i), "Total Fosfor") <> O Then
    col = 8
    ElseIf InStr(Worksheets("results").Cells(1, i), "Total Nitrogen") <> O Then
    col = 9
    ElseIf InStr(Worksheets("results").Cells(1, i), "Turbiditet") <> O Then
    col = 12
    ElseIf InStr(Worksheets("results").Cells(1, i), "TOC") <> O Then
    col = 15
    ElseIf InStr(Worksheets("results").Cells(1, i), "Fargetall") <> O Then
    col = 13
    ElseIf InStr(Worksheets("results").Cells(1, i), "Suspendert stoff") <> O Then
    col = 17
    ElseIf InStr(Worksheets("results").Cells(1, i), "Termotolerante Koliforme") <> O Then
    col = 18
    ElseIf InStr(Worksheets("results").Cells(1, i), "Ammonium") <> O Then
    col = 19
    Else
    GoTo NextIteration

    End If

    Worksheets("Sheet4").Cells(j, col).Value = Worksheets("results").Cells(j, i).Value

    i = i + 1
    Loop
    NextIteration:
    j = j + 1
    Loop

    End Sub
     
  2. lunarlander

    lunarlander

    Joined:
    Sep 21, 2007
    Messages:
    11,876
    If Ammonium is never reached, then the looping would fail somewhere. Use another kind of loop.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Tags:
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1229877

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice