Results 1 to 8 of 8

Problem with loop

Threaded View

  1. #1
    Registered User
    Join Date
    02-23-2014
    Location
    Hjørring, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    16

    Problem with loop

    I am new to VBA in Excel and need help in looping. I have different data from a sheet "PakkeIndtag" that I need to copy to different cells in other sheet "Data". My loop works almost perfectly. One thing I can't find out is how to jump over row 46 which is in the end of mu loop.If you look at the uploaded picture 1, you can see that I need to come over row 46 then it repeats all over again. The next yellow row will come at row 89 and so on, and so on, every 43 rows. Everything in-between yellow rows is the same as shown on the image.

    My code is as follows
    Sub Analyse_data()
    Dim i, MaskinTid As Single
    Dim Aar, Uge, Dag, MaskinStop, StopType, Station As String
    i = 4
    n = 5
    j = 2
    Application.ScreenUpdating = False
    
    Sheets("PakkeIndtag").Select
    Station = Cells(1, 1).Value
    Do Until Cells(i, 1).Value = ""
        Do Until Cells(n, 1).Value = ""
            Dag = Cells(i, 1).Value
            Uge = Cells(i, 2).Value
            Aar = Cells(i, 6).Value ' Skal justeres til
            MaskinStop = Cells(n, 1).Value
            StopType = Cells(n, 3).Value
            MaskinTid = Cells(n, 4).Value
            Sheets("Data").Select
            Cells(j, 1).Select
            Cells(j, 1).Value = Station
            Cells(j, 2).Value = MaskinStop
            Cells(j, 3).Value = StopType
            Cells(j, 4).Value = MaskinTid
            Cells(j, 5).Value = Dag
            Cells(j, 6).Value = Uge
            Cells(j, 7).Value = Aar
            Sheets("PakkeIndtag").Select
            j = j + 1
            n = n + 1
        Loop
        i = i + 6
        n = i + 1
    Loop
    Application.ScreenUpdating = True
    End Sub
    I hope somebody can help me with this problem
    Attached Images Attached Images
    Last edited by Leith Ross; 02-23-2014 at 04:21 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. Vlookup problem in a loop with cell property and variable cell problem (long title sry)
    By ExcelsiorLux in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 10:38 AM
  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. Loop problem
    By Rams in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-01-2011, 09:50 AM
  4. For Each Next Loop Problem
    By jdbegg in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-20-2006, 10:52 PM
  5. [SOLVED] Problem adding charts using Do-Loop Until loop
    By Chris Bromley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2005, 09:06 AM

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