ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Place rectangle and define its height? (https://www.excelbanter.com/excel-programming/375356-place-rectangle-define-its-height.html)

tskogstrom

Place rectangle and define its height?
 
I Have a rectangle I want to place at a location and set it's height.
To do that, I have "top" and "bottom" named ranges. Here are
specifications and what I tried:

'RAPP_REC_CASHFLOW = Rectangle name
'RAPP_TOP = Top of rectangle (= named range B2:G2)
'RAPP_BOTT = Bottom of rectangle (= named range B16:G16)

Tried with this, silly old me:-) :

Dim rng As Range
Set rng = Application.Union(Range("RAPP_TOP"), Range("RAPP_BOTT"))
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Top = Range("RAPP_TOP").Top
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Height = rng.Height

rng.Height make just one row of height ...
Any out there who can help?

kind regards
tskogstrom


Bob Phillips

Place rectangle and define its height?
 
Dim rng As Range
Set rng = Application.Union(Range("RAPP_TOP"), Range("RAPP_BOTT"))
With ActiveSheet.Shapes("RAPP_REC_CASHFLOW")
.Top = rng.Top
.Height = Range("RAPP_BOTT").Top - Range("RAPP_TOP").Top
.Left = rng.Left
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"tskogstrom" wrote in message
oups.com...
I Have a rectangle I want to place at a location and set it's height.
To do that, I have "top" and "bottom" named ranges. Here are
specifications and what I tried:

'RAPP_REC_CASHFLOW = Rectangle name
'RAPP_TOP = Top of rectangle (= named range B2:G2)
'RAPP_BOTT = Bottom of rectangle (= named range B16:G16)

Tried with this, silly old me:-) :

Dim rng As Range
Set rng = Application.Union(Range("RAPP_TOP"), Range("RAPP_BOTT"))
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Top = Range("RAPP_TOP").Top
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Height = rng.Height

rng.Height make just one row of height ...
Any out there who can help?

kind regards
tskogstrom




NickHK

Place rectangle and define its height?
 
Think you want to use Range instead of Union. See the difference between
these 2 values :

Dim rng As Range

Set rng = Union(Range("A1"), Range("C3"))
MsgBox rng.Height

Set rng = Range(Range("A1"), Range("C3"))
MsgBox rng.Height

NickHK
P.S. Whilst not wrong, use of "Let" is largely ignored nowadays, as it is
optional. "Set" is required though.

"tskogstrom" wrote in message
oups.com...
I Have a rectangle I want to place at a location and set it's height.
To do that, I have "top" and "bottom" named ranges. Here are
specifications and what I tried:

'RAPP_REC_CASHFLOW = Rectangle name
'RAPP_TOP = Top of rectangle (= named range B2:G2)
'RAPP_BOTT = Bottom of rectangle (= named range B16:G16)

Tried with this, silly old me:-) :

Dim rng As Range
Set rng = Application.Union(Range("RAPP_TOP"), Range("RAPP_BOTT"))
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Top = Range("RAPP_TOP").Top
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Height = rng.Height

rng.Height make just one row of height ...
Any out there who can help?

kind regards
tskogstrom




tskogstrom

Place rectangle and define its height?
 
You were right, Nick
It is Range(rage1, range2) method I tried to find.
Regards
tskogstrom


NickHK skrev:

Think you want to use Range instead of Union. See the difference between
these 2 values :

Dim rng As Range

Set rng = Union(Range("A1"), Range("C3"))
MsgBox rng.Height

Set rng = Range(Range("A1"), Range("C3"))
MsgBox rng.Height

NickHK
P.S. Whilst not wrong, use of "Let" is largely ignored nowadays, as it is
optional. "Set" is required though.

"tskogstrom" wrote in message
oups.com...
I Have a rectangle I want to place at a location and set it's height.
To do that, I have "top" and "bottom" named ranges. Here are
specifications and what I tried:

'RAPP_REC_CASHFLOW = Rectangle name
'RAPP_TOP = Top of rectangle (= named range B2:G2)
'RAPP_BOTT = Bottom of rectangle (= named range B16:G16)

Tried with this, silly old me:-) :

Dim rng As Range
Set rng = Application.Union(Range("RAPP_TOP"), Range("RAPP_BOTT"))
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Top = Range("RAPP_TOP").Top
Let ActiveSheet.Shapes("RAPP_REC_CASHFLOW").Height = rng.Height

rng.Height make just one row of height ...
Any out there who can help?

kind regards
tskogstrom




All times are GMT +1. The time now is 05:14 AM.

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