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
Bookmarks