Sarah, I have edited what you posted to what should be a working macro. However, it is still using some static offsets "RC[2]:RC[29]" and I don't know what these are referring to.
I can see that you are just using the record macro feature and checking it out. Have you had any programming experience before now?
Code:Sub lkjslkfjd() Dim EndRange As Range Dim LastRow As String Dim s As String Columns("F:F").Select 'This will return the last row used. 'ASSUMES: All values are filled in starting with row 1 and ' there are no empty cells all the way to the end. Set EndRange = Selection.End(xlDown) LastRow = CStr(EndRange.Row) Selection.Insert Shift:=xlToRight Range("G2").Select Selection.AutoFill Destination:=Range("F2:G2"), Type:=xlFillDefault Range("F2:G2").Select Columns("F:F").EntireColumn.AutoFit Range("B4").Select ActiveCell.FormulaR1C1 = "=COUNTA(RC[4]:RC[17])" s = Replace("B4:B?", "?", LastRow) Selection.AutoFill Destination:=Range(s), Type:=xlFillDefault Range("D4").Select ActiveCell.FormulaR1C1 = "=COUNTA(RC[2]:RC[29])" s = Replace("D4:D?", "?", LastRow) Selection.AutoFill Destination:=Range(s), Type:=xlFillDefault Range("H2").Select Selection.AutoFill Destination:=Range("G2:H2"), Type:=xlFillDefault Columns("G:G").Select Selection.Copy Columns("F:F").Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False Range("G" & LastRow).Select s = Replace("F?:G?", "?", LastRow) Selection.AutoFill Destination:=Range(s), Type:=xlFillDefault Range("F4").Select End Sub




Reply With Quote