Consulting

Results 1 to 3 of 3

Thread: Problemen met de loop functie

  1. #1
    VBAX Newbie
    Joined
    Oct 2016
    Posts
    2
    Location

    Problemen met de loop functie

    Hallo,
    Ik heb een probleempje met mijn code. ik heb een code nodig die values van cellen van het ene blad naar het andere kopieerd. Ik heb een loop nodig die dit doet tot hij terug aan de value van de eerste cell komt en dan stopt. Ik heb een code gemaakt die werkt, maar als ik aan de code andere voorwaarden hang, blijft de loop doorlopen. In de code hieronder ben ik opzoek naar cellen waar "1 X" in voorkomt bv "1 X kast". als ik mijn code dan aanpas om bv "2 X" te vinden blijft de loop doorlopen en kopieren en plakken. Niet echt ideaal .

    Dim A As Range
    Sheet5.Activate
        Cells.Find(what:="1 X ", after:=ActiveCell, LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False _
            , searchformat:=False).Copy
    ActiveCell.Select
    Set A = ActiveCell
    Sheet75.Activate
    row_number = row_number + 1
    Cells(row_number, 2).Select
    ActiveCell.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
    Do
    Blad5.Activate
    Cells.FindNext(after:=ActiveCell).Select
    Cells.FindNext(after:=ActiveCell).Copy
    Sheet75.Activate
    row_number = row_number + 1
    Cells(row_number, 2).Select
    ActiveCell.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
    Loop Until ActiveCell.Value = A.Value
    Alvast bedankt
    Last edited by SamT; 10-06-2016 at 07:13 AM.

  2. #2
    VBAX Newbie
    Joined
    Oct 2016
    Posts
    2
    Location

    Problem loop function VBA Excel

    Hi guys,
    I need your help to get my code working. I made a code to copy values of cell from one sheet to another, i needed a loop in the code to copy all the values and stop when the first value reached again. So far so good. But when i change the code to find other things (example "2 X" with B as range) the loop keeps going and pasting values in my sheet, and can't be stopt.
    Below is the code that works.
    SO i need a code that does the same, but with different terms, i hope you guys can help me.

    Dim A As Range
     Sheet5.Activate
        Cells.Find(what:="1 X ", after:=ActiveCell, LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=False _
            , searchformat:=False).Copy
     ActiveCell.Select
     Set A = ActiveCell
     Sheet75.Activate
     row_number = row_number + 1
     Cells(row_number, 2).Select
     ActiveCell.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
     Do
     Blad5.Activate
     Cells.FindNext(after:=ActiveCell).Select
     Cells.FindNext(after:=ActiveCell).Copy
     Sheet75.Activate
     row_number = row_number + 1
     Cells(row_number, 2).Select
     ActiveCell.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=False, Transpose:=False
     Loop Until ActiveCell.Value = A.Value
    Thank you and srry for bad english.
    Last edited by SamT; 10-06-2016 at 07:13 AM.

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    This was two threads, the English language post was in the Excel Folder.
    I also edited the two by using the # icon to add Code Formatting Tags.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •