Command for Fill Effect in Excel VBA

2

Friends, I'm using the hint, described in the "Excel Guru" script in Creating Interactive Maps in Excel:

Sub ColorirMapa()

Dim Microareas As Range 
Dim Celula As String 

For Each Microareas In Range (“Microareas”)
Celula = Cells (Microareas.Row, 4)
ActiveSheet.Shapes(Microareas).Fill.ForeColor.RGB = Range(Celula).Interior.Color
Next Regiao

End Sub

What would be the command in Visual Basic for Applications (VBA) to put dotted texture, striped or other type fill effect - instead of colors?

    
asked by anonymous 03.11.2014 / 21:36

1 answer

4

You would need to enter the following Interior properties of your Cell object to have the desired effect:

Range(Celula).Select

With Selection.Interior
    .Pattern = xlVertical
    .PatternColorIndex = xlAutomatic
    .Color = 5296274
    .TintAndShade = 0
    .PatternTintAndShade = 0
End With

It would look something like this:

GoldenHint

WeoftenwanttoturnVBAcodeintoformatting,lists,freezecolumnsbutwehavenoideawheretostart.ExcelhasafeaturethatletsyourecordtheactionsyouperformandtransformsintoVBAcodesforyou.

Althoughthegeneratedcodeisnotideal,itcaterstomostcasesandgivesyouanideaofhowtodowhatyouwant.

  • Enablethe"Developer" tab of your Excel, under File > Options > Customize ribbon.
  • Select Record Macro
  • Do whatever you want in Excel. Finished what you needed to do, stop running the macro and analyze the generated code
  •     
    04.11.2014 / 02:57