locked
Powershell script to TRIM excel entire column RRS feed

  • Question

  • Hi Guys ,

    I am facing issue to trim the entire excel column using powershell .Below code I have used but it replace the entire cell value on search of space.

    I am avoiding the use of loops. Please help

    
    $optionalParameter = [System.Type]::Missing  
    $Worksheet.Range("B2").EntireColumn.Replace(" ", "",2,$optionalParameter,$optionalParameter,$false,$false,$true)


    • Edited by Fabcoder Thursday, October 4, 2018 5:26 AM
    Thursday, October 4, 2018 5:07 AM

Answers

  •  
    $optionalParameter = [System.Type]::Missing
    $Worksheet.Range("B2").EntireColumn.Replace(" ", "",$optionalParameter,$optionalParameter,$optionalParameter,$optionalParameter,$optionalParameter,$optionalParameter)
    

    This working successfully !!
    • Marked as answer by Fabcoder Thursday, October 4, 2018 7:50 AM
    Thursday, October 4, 2018 7:50 AM