If there is a value already in Column A that you are using to determine the last row, then this should fill the value that is in "A5", down to one cell above the last row.
[VBA]Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A5").AutoFill .Range("A5:A" & LastRow - 1), Type:=xlFillDefault
End With[/VBA]
Thanks Frank but it worked only if i put it in sub procedure and call it in the main, if i put it directly to main a run time error occured " class failed"
Can you through together a sample workbook that fails so I see what you mean? - Or at least more of your main sub code. And a perhaps a little more detail of the data and sheet structure.
Do you mean that there is a problem with running Macro7? By running the Main "macro", I think that you mean running CommandButton1_Click.
A problem, run-time error 1004, when running Macro7 after the CommandButton1_Click is that you did not unprotect the sheet as you did in the latter routine. Rather than doing all that unprotect and protect for each sheet, I recommend doing this sort of thing for each sheet:
[vba] Sheets("start").Protect UserInterfaceOnly:=True[/vba]
This allows your code to change sheet data but not manual changes by the user. I normally do this in the Open event of the ThisWorkbook object but it should be done for each newly added sheet if your code will then modify the data.