How to get coordinates of column for positioning a shape location?

biocentrism

Board Regular
Joined
Jul 28, 2014
Messages
187
Hello

I am drawing a line on a sheet using:
Code:
    'Insert Line
    ActiveSheet.Shapes.AddLine(755, 165, 755, 450).Select
    Selection.ShapeRange.ShapeStyle = msoLineStylePreset3
    With Selection.ShapeRange.Line
        .Visible = msoTrue
        .Weight = 1.5
    End With

The arguments are AddLine(x-Start, y-Start, x-End, y-End).Select.

How would I set a variable in place of the the numeric coordinates which would equal "the middle of column Q" for example?

My sheet has columns that vary in width depending on the length of the data in the cells. So I would like the line to be positioned such that x-Start and x-End = "the middle of Column Q".

Can this be done?

Thank you.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Ranges have Top, Left, Width and Height properties, so you can calculate from that. Note: it is safest to set the window zoom to 100% before you start trying to position shapes.
 
Upvote 0

Forum statistics

Threads
1,203,514
Messages
6,055,838
Members
444,828
Latest member
StaffordStag

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