Hello everyone,
I have a macro set up that asks for a beginning date and an ending date, then scans columns J-Y for a date that falls within that range. If the macro finds a valid date, it copies and pastes the cell containing the date and the cell directly to the right of it onto another sheet (ex: if date is in column J, it copies J+K from that row).
What I need it to do is copy and paste the cells in columns B,D,E,F,G, as well as the cell containing the date and the cell directly to the right (all from the same row). I can't figure out how to alter the code to capture non-adjacent cells in the row.
BONUS: It would be great if the macro just copied the values in the cells without formatting. This isn't necessary for the purpose of the sheet, but it would make everything look cleaner.
I've been researching this code for 2-3 weeks now and I finally have to throw in the towel and ask for advice from brilliant people like yourselves. Any help would be greatly appreciated.
I have a macro set up that asks for a beginning date and an ending date, then scans columns J-Y for a date that falls within that range. If the macro finds a valid date, it copies and pastes the cell containing the date and the cell directly to the right of it onto another sheet (ex: if date is in column J, it copies J+K from that row).
What I need it to do is copy and paste the cells in columns B,D,E,F,G, as well as the cell containing the date and the cell directly to the right (all from the same row). I can't figure out how to alter the code to capture non-adjacent cells in the row.
BONUS: It would be great if the macro just copied the values in the cells without formatting. This isn't necessary for the purpose of the sheet, but it would make everything look cleaner.
I've been researching this code for 2-3 weeks now and I finally have to throw in the towel and ask for advice from brilliant people like yourselves. Any help would be greatly appreciated.
Code:
Sub SanDiego_Releases()
Dim startdate As Date, enddate As Date
Dim rng As Range, destRow As Long
Dim shtSrc As Worksheet, shtDest As Worksheet
Dim c As Range
Set shtSrc = Sheets("San Diego")
Set shtDest = Sheets("RELEASE SCHEDULE")
destRow = 3
startdate = CDate(InputBox("Beginning Date"))
enddate = CDate(InputBox("End Date"))
Set rng = Application.Intersect(shtSrc.Range("J:Y"), shtSrc.UsedRange)
For Each c In rng.Cells
If c.Value >= startdate And c.Value <= enddate Then
'I assume the below is where the problem is...
c.Offset(1, 0).Resize(1, 2).Copy _
shtDest.Cells(destRow, 4)
destRow = destRow + 1
End If
Next
End Sub