I am using a macro to add a row to a named range and then sort the range into alphabetical order.
I have code on another sheet where it's working, but I just cannot get it to work on the second one, and I don't know why.
I tried naming the cell I want to use as sorting criteria (Timing_S) but that didn't help. I even tried recording the sort macro and using the code from that and it didn't work (and included a lot of ActiveWorkbook stuff that I don't usually see and I only had one workbook open)
Help?
This is the code that's giving me grief
This is the code that's working
I have code on another sheet where it's working, but I just cannot get it to work on the second one, and I don't know why.
I tried naming the cell I want to use as sorting criteria (Timing_S) but that didn't help. I even tried recording the sort macro and using the code from that and it didn't work (and included a lot of ActiveWorkbook stuff that I don't usually see and I only had one workbook open)
Help?
This is the code that's giving me grief
Code:
Range("Timing").Select
Selection.Offset(2, 0).EntireRow.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Range("A3:T3").Borders.LineStyle = xlContinuous
ActiveCell.Range("A2:T2").Select
Selection.Autofill Destination:=ActiveCell.Range("A1:T2"), Type:= _
xlFillDefault
Selection.Replace What:="SiteTemplate", Replacement:="yule", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("Timing").Offset(0, 1).Select
Range("Site_Report").Sort key1:=ActiveCell, Header:=xlYes
This is the code that's working
Code:
Range("CountryAdd2").Select
Dim existing As String
existing = ActiveCell.Offset(7, 0).Value
Range("CountryAdd2").Offset(7, 0).EntireRow.Select
ActiveCell.Rows("1:4").EntireRow.Select
Selection.Insert Shift:=x1Down, CopyOrigin:=xlFormatFromRightOrBelow
ActiveCell.Offset(4, 0).Range("A1:H4").Select
Selection.Autofill Destination:=ActiveCell.Offset(-4, 0).Range("A1:H8"), Type _
:=xlFillDefault
ActiveCell.Offset(-4, 0).Range("A1:H4").Select
Selection.Replace What:=existing, Replacement:=country, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("CountryAdd2").Offset(0, 6).Select
Range("Site_Report").Sort key1:=ActiveCell, Header:=xlYes