For Each red As DataGridViewRow In DataGridView1.Rows Dim rednibroj As Integer = DataGridView2.Rows.Count - 1 If broj = 1 Then Dim length As Integer = Trim(red.Cells(1).Value.Replace(" ", "")).Length If length > 3 Then DataGridView2.Rows.Add(Trim(red.Cells(1).Value).Replace(" ", "")) broj = 2 ElseIf length > 1 And length < 4 Then broj_dana_blokade = Trim(DataGridView1.Rows(DataGridView1.Rows.Count - 1).Cells(1).Value.Replace(" ", "")) TextBox1.Text = broj_dana_blokade.ToString End If ElseIf broj = 2 Then DataGridView2.Rows(rednibroj).Cells(1).Value = Trim(DataGridView1.Rows(rednibroj * 3 + 1).Cells(1).Value.Replace(" ", "")) broj = 3 ElseIf broj = 3 Then DataGridView2.Rows(rednibroj).Cells(2).Value = Trim(DataGridView1.Rows(rednibroj * 3 + 2).Cells(1).Value.Replace(" ", "")) broj = 1 End If Next