Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Lines 1

Status
Not open for further replies.

Dan15

Technical User
Dec 23, 2002
66
US
What is the code for a macro to inserta line in Excel while maintaining the formulas for that column? It must be relative to the active cell selected.

Thanks-
-Dan
 
Use the .borders property of the range object. For example, the following code puts a medium-weight line to the left of the active cell, along the entire column boundary.

activecell.EntireColumn.Borders(xlEdgeLeft).Weight=xlmedium

Rob
[flowerface]
 
To clarify, I meant to say insert another row. I need to insert a row, copying the formulas from the row above. When you try to do this through recording the macro, it doesn't give the code in relative terms. I need to be able to insert the row anywhere and maintain the spreadsheet formulas.
 
One way to do this would be:

activecell.EntireRow.Insert
activecell.offset(-1,0).EntireRow.Copy activecell.EntireRow
activecell.EntireRow.SpecialCells(xlCellTypeConstants).clear

This inserts the row, copies the entire row above, and the clears the constants, leaving just the formulas.
Rob
[flowerface]
 
Rob-

This is exactly what I'm looking for. Thank you very much-

-Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top