0

Struggling to get a grasp of automating inserting data in to Excel with Powershell. So far I have managed to get columns with the correct date inserted in to sheets that match our cluster names. I am now hoping to pick values from a named range in an existing spreadsheet and then past the values in to a cell.

I have been able to find lots of pieces around creating a range and naming it but nothing that I can really understand to help me address an existing range. My COM understanding is limited but I am slowly piecing bit together - suspect I am missing something fundamental.

I thought I was close with the following:

[void]$SrcWorkSheet.Range("ClusterName",11).Copy()

But this seems to return an error that suggests backward compatability woth 2007 is causing the issue.

Exception from HRESULT: 0x800A03EC

I am eventually hoping to replace "ClusterName" with a variable I am looping through so it is repeateable across multiple sheets.

2
  • What are you trying to achieve with that "11" in Range("ClusterName",11)? If you want to select your named range you should just get it by Range("ClusterName") Feb 1, 2017 at 10:33
  • apologies, was trying to select the 11th row of the named range, I suppose similar to the =INDEX() formula in excel
    – user275560
    Feb 1, 2017 at 10:59

1 Answer 1

2

If you need to copy just the 11th row in your range,

$SrcWorkSheet.Range("ClusterName").Rows(11).Copy()
1
  • Ah, I get it now. Thanks very much, worked like a charm
    – user275560
    Feb 1, 2017 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy