By recording a Macro, you can develop the following code snipet:
Expand|Select|Wrap|Line Numbers
- Sub Macro1()
- '
- ' Macro1 Macro
- ' Macro recorded 9/16/2009 by Ebernon
- '
- '
- Rows("1:20").Select
- Selection.Delete Shift:=xlUp
- End Sub
To resolve this problem, the following snippet provides for the Dynamic setting of the Rows to be deleted by using the Range Object method:
Expand|Select|Wrap|Line Numbers
- Sub Macro2()
- '
- ' Macro2 Macro
- ' Macro recorded 9/16/2009 by Ebernon
- '
- '
- N1 = 20
- N2 = 1
- Range(Rows(N1), Rows(N2)).Select
- Selection.Delete Shift:=xlUp
- End Sub
For Columns, simply substitute the "Range(Columns(N1),Columns(N2)).Select" for the Range to be deleted.
Final Note: Be careful when deleting cells to which links have been added, this will cause errors to appear in the cells or ranges that have been linked to the deleted cell.
Happy Programming!!!