ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need coding to DELETE a line on a spreadsheet. (https://www.excelbanter.com/excel-programming/351057-need-coding-delete-line-spreadsheet.html)

Ed

Need coding to DELETE a line on a spreadsheet.
 
Hi

With Worksheets("SpeedPlay").Shapes.AddLine(546, 90, 546, 114)
..Line.ForeColor.RGB = RGB(0, 0, 0)
End With

The preceding Macro code adds a black line of a certain length and in a
certain place on a spreadsheet named SpeedPlay.

What I need is the coding to DELETE (remove) this same line.
Is that possible?

Thankyou
Ed

Chip Pearson

Need coding to DELETE a line on a spreadsheet.
 
Ed,

Give the line a name,

With Worksheets("SpeedPlay").Shapes.AddLine(546, 90, 546, 114)
..Line.ForeColor.RGB = RGB(0, 0, 0)
..Name = "TheLine"
End With

Then, reference the line via the Shapes collection and delete it.

Worksheets("SpeedPlay").Shapes("TheLine").Delete


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Ed" wrote in message
...
Hi

With Worksheets("SpeedPlay").Shapes.AddLine(546, 90, 546, 114)
.Line.ForeColor.RGB = RGB(0, 0, 0)
End With

The preceding Macro code adds a black line of a certain length
and in a
certain place on a spreadsheet named SpeedPlay.

What I need is the coding to DELETE (remove) this same line.
Is that possible?

Thankyou
Ed





All times are GMT +1. The time now is 05:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com