Drawing a Rectangle

adrian.groves

New Member
Joined
Aug 29, 2012
Messages
18
Hi,

I am trying to draw rectangles using a set of variables and I can draw a solid box using:

With plotsheet.Shapes.AddShape(1, Startx, Starty, BoxWidth, BoxHeight).Fill
.ForeColor.RGB = RGB(Red, Blue, Green)
.BackColor.RGB = RGB(Red, Blue, Green)
End With

(The items in italics are variables.)




The problem comes when I try to define a fill style and I have tried:

With plotsheet.Shapes.AddShape(1, Startx, Starty, BoxWidth, BoxHeight).Fill
.ForeColor.RGB = RGB(Red, Blue, Green)
.BackColor.RGB = RGB(Red, Blue, Green)
.Interior.Pattern = xlPatternCrissCross
End With


I am trying to set a transparency and a pattern type of vertical lines. Can anybody offer any assistance to what the ".Interior.Pattern = xlPatternCrissCross" should be replaced with?

Thanks
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

KKaren

New Member
Joined
Jan 13, 2018
Messages
33
Hi,

I recorded a macro and it suggested the following syntax for the pattern, but you may choose some of the different constants instead of msoPatternVertical

Code:
    With plotsheet.Shapes.AddShape(1, Startx, Starty, BoxWidth, BoxHeight).Fill
        .ForeColor.RGB = RGB(Red, Blue, Green)
        .BackColor.RGB = RGB(Red, Blue, Green)
        .Patterned msoPatternVertical
    End With
 

adrian.groves

New Member
Joined
Aug 29, 2012
Messages
18
KKaren,

Thank you. That worked perfectly

I had been trying several different options for quite a while this afternoon. Thanks again

Adrian
 

Watch MrExcel Video

Forum statistics

Threads
1,099,491
Messages
5,468,916
Members
406,620
Latest member
Gitani123

This Week's Hot Topics

Top