Replace Line with a shape (Rectangle)

NerillaW

New Member
Joined
Nov 23, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I have created an excel file with lot of lines but I want to change all the line I have into Rectangles with specific Withd and Height, and they should be inserted where the lines where. I tried the replace shape but only works with other shapes but not lines. Any VBA code I can try?

Thank you all in advance,
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
with specific Withd and Height,
then change 25 and 5 I guess. My sheet name was D so you need to change that as well.
VBA Code:
Sub NerillaW()
Dim shp As Shape
Dim x As Integer, y As Integer

For Each shp In Sheets("D").Shapes
    If shp.AutoShapeType = -2 Then
        x = shp.Left
        y = shp.Top
        shp.Delete
        Shapes.AddShape msoShapeRectangle, x, y, 25, 5
    End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,504
Messages
6,125,183
Members
449,212
Latest member
kenmaldonado

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top