Macro: Offset row

muizac

Board Regular
Joined
Oct 24, 2006
Messages
50
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
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
* bump * (sorry - my first ever bump, but I'm pretty stuck without getting past this hurdle)
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top