Hi there,
Can anyone please tell me how to offset a row in the macro below? My data is to display side-by-side in columns, unfortunately it's skipping rows as soon as it gets to columns 3, so that columns 1 & 2 are showing in all the odd rows (ie - A1,A3,A5) and columns 3&4 are going to even rows (C2,C4,C6). I'd like it whereby it does not miss out rows, so all column 1 will populate A1 > A10, Column 2 B1 > B10, Column 3 C1 ? C10 etc
Many thanks,
Andrew
Here's my macro:
Sub Week()
Dim rngWeek As Range
Dim rngCell As Range
Dim Count As Long
Set rngWeek = Worksheets("Schedule").Range("D2:D5000")
For Each rngCell In rngWeek
If rngCell > DateAdd("d", -1, Date) And rngCell < DateAdd("d", 8, Date) Then
Count = Count + 1
Worksheets("Week").Cells(Count, 1).Value = rngCell.Offset(0, -1).Value
Worksheets("Week").Cells(Count, 2).Value = rngCell.Value
End If
If rngCell > DateAdd("d", -1, Date) And rngCell < DateAdd("d", 8, Date) Then
Count = Count + 1
Worksheets("Week").Cells(Count, 3).Value = rngCell.Offset(0, -1).Value
Worksheets("Week").Cells(Count, 4).Value = rngCell.Value
End If
Next
End Sub
Can anyone please tell me how to offset a row in the macro below? My data is to display side-by-side in columns, unfortunately it's skipping rows as soon as it gets to columns 3, so that columns 1 & 2 are showing in all the odd rows (ie - A1,A3,A5) and columns 3&4 are going to even rows (C2,C4,C6). I'd like it whereby it does not miss out rows, so all column 1 will populate A1 > A10, Column 2 B1 > B10, Column 3 C1 ? C10 etc
Many thanks,
Andrew
Here's my macro:
Sub Week()
Dim rngWeek As Range
Dim rngCell As Range
Dim Count As Long
Set rngWeek = Worksheets("Schedule").Range("D2:D5000")
For Each rngCell In rngWeek
If rngCell > DateAdd("d", -1, Date) And rngCell < DateAdd("d", 8, Date) Then
Count = Count + 1
Worksheets("Week").Cells(Count, 1).Value = rngCell.Offset(0, -1).Value
Worksheets("Week").Cells(Count, 2).Value = rngCell.Value
End If
If rngCell > DateAdd("d", -1, Date) And rngCell < DateAdd("d", 8, Date) Then
Count = Count + 1
Worksheets("Week").Cells(Count, 3).Value = rngCell.Offset(0, -1).Value
Worksheets("Week").Cells(Count, 4).Value = rngCell.Value
End If
Next
End Sub