Categories

Excel–named range

To create a named range in an Excel spreadsheet

$xl = New-Object -ComObject 'Excel.Application'
$wkbk = $xl.Workbooks.Add()
$sheet = $wkbk.WorkSheets.Item(1)
$range = $xl.Range("A1", "D4")
$range.Name = "Test"

Just to show how to work with named ranges

$range2 = $xl.Range("Test")
$range2.Borders.Color=0
$range2.Borders.ColorIndex=26
$range2.Borders.Weight=2
$xl.visible = $true

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>