RafFiniert
New Member
- Joined
- Mar 18, 2025
- Messages
- 7
- Office Version
- 2013
- Platform
- Windows
Among other tips/tricks, I read that I should rid my code of all .Select statements. I have done so by and large. However, I am stuck on this one.
(Original code that works)
Worksheets("DM2").Select
Worksheets("DM2").Range("A5:J5").Select
Worksheets("DM2").Range("A5:J5").Copy
Worksheets("Routes").Select
Worksheets("Routes").Range("A3:A3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("FromHereSubsequently").PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("DriveTime").Copy
Worksheets("Routes").Range("H3:H3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(0, 7).PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("ArriveTime").Copy
Worksheets("Routes").Range("I3:I3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(0, 8).PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("EndTime").Copy
Worksheets("Routes").Range("J3:J3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(0, 9).PasteSpecial xlPasteValues
(What I tried that doesn't work)
Worksheets("Routes").Range("A3:A3").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Worksheets("DM2").Range("A5:J5").Value
Worksheets("NamedRanges").Range("FromHereSubsequently").Value = Worksheets("DM2").Range("A5:J5").Value
Worksheets("Routes").Range("H3:H3").Cells(Rows.Count, 1).End(xlUp).Offset(0, 7).Value = Worksheets("NamedRanges").Range("DriveTime").Value
Worksheets("Routes").Range("I3:I3").Cells(Rows.Count, 1).End(xlUp).Offset(0, 8).Value = Worksheets("NamedRanges").Range("ArriveTime").Value
Worksheets("Routes").Range("J3:J3").Cells(Rows.Count, 1).End(xlUp).Offset(0, 9).Value = Worksheets("NamedRanges").Range("EndTime").Value
Based on how I got rid of my other .Select/.Copy statements, it seems intuitive that this should work. Only it doesn't.
(Original code that works)
Worksheets("DM2").Select
Worksheets("DM2").Range("A5:J5").Select
Worksheets("DM2").Range("A5:J5").Copy
Worksheets("Routes").Select
Worksheets("Routes").Range("A3:A3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("FromHereSubsequently").PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("DriveTime").Copy
Worksheets("Routes").Range("H3:H3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(0, 7).PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("ArriveTime").Copy
Worksheets("Routes").Range("I3:I3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(0, 8).PasteSpecial xlPasteValues
Worksheets("NamedRanges").Range("EndTime").Copy
Worksheets("Routes").Range("J3:J3").Select
Worksheets("Routes").Cells(Rows.Count, 1).End(xlUp).Offset(0, 9).PasteSpecial xlPasteValues
(What I tried that doesn't work)
Worksheets("Routes").Range("A3:A3").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value = Worksheets("DM2").Range("A5:J5").Value
Worksheets("NamedRanges").Range("FromHereSubsequently").Value = Worksheets("DM2").Range("A5:J5").Value
Worksheets("Routes").Range("H3:H3").Cells(Rows.Count, 1).End(xlUp).Offset(0, 7).Value = Worksheets("NamedRanges").Range("DriveTime").Value
Worksheets("Routes").Range("I3:I3").Cells(Rows.Count, 1).End(xlUp).Offset(0, 8).Value = Worksheets("NamedRanges").Range("ArriveTime").Value
Worksheets("Routes").Range("J3:J3").Cells(Rows.Count, 1).End(xlUp).Offset(0, 9).Value = Worksheets("NamedRanges").Range("EndTime").Value
Based on how I got rid of my other .Select/.Copy statements, it seems intuitive that this should work. Only it doesn't.