Jump to content

Recommended Posts

Posted (edited)

Not sure what's going on with my script, but when I range read the contents in column A and then write them to column E it inserts the contents but it also inserts #N/A after all the way down to row  1048576. What am I missing from my script? Below is my script

 

Edited by goku200
Posted

A few thoughts:

  • _Excel_SheetAdd: You can't have multiple sheets with the same name ("Test") in a workbook
  • _Excel_RangeDelete: If you want to delete row 1 then delete row 1, not all cells in this row. Means: _Excel_RangeDelete($oWorkbook.ActiveSheet, "1:1")
    Your parameter 3 with the value of 2 is definitely wrong.
  • _Excel_RangeInsert: Your parameter 3 with the value of 2 is definitely wrong.
  • _Excel_RangeDelete: When deleting a column using parameter $xlShiftUp doesn't make sense.
  • Check the dimensions (number of rows and columns) of $Array2. How many rows/columns do you get?
  • You should check @error / @extended after each _Excel_* function call

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)
  On 2/14/2022 at 8:55 AM, water said:

A few thoughts:

  • _Excel_SheetAdd: You can't have multiple sheets with the same name ("Test") in a workbook
  • _Excel_RangeDelete: If you want to delete row 1 then delete row 1, not all cells in this row. Means: _Excel_RangeDelete($oWorkbook.ActiveSheet, "1:1")
    Your parameter 3 with the value of 2 is definitely wrong.
  • _Excel_RangeInsert: Your parameter 3 with the value of 2 is definitely wrong.
  • _Excel_RangeDelete: When deleting a column using parameter $xlShiftUp doesn't make sense.
  • Check the dimensions (number of rows and columns) of $Array2. How many rows/columns do you get?
  • You should check @error / @extended after each _Excel_* function call
Expand  

@water Thank you for the reply. I went ahead and updated the script with 1:1. The script only creates one Worksheet Test. The first tab is by default Sheet1 when script runs it creates second tab sheet (Test). I also changed the _ExcelRangeDelete to $xlshiftDown for Column A since that is what's being deleted...The dimensions of $Array2 displays the correct Column A with the contents in it. The reason why I have the _ExcelRangeInsert with column E:E is because my data varies. It could be 100 rows, 200 rows, or 1000 rows....

Edited by goku200
Posted (edited)

I am having a bit of hard time to follow your script.  But here are my thoughts (since this code is unrunable for me) :

1- remove those lines from the loop as they are repeating redundantly the same things

_Excel_SheetAdd($oWorkbook, -1, False, 1, "Test")
 Local $FileList = _FileListToArray("C:\Test\", "*.*")
_ArrayDisplay($aArray2)

2- You are writing a single value to the whole column (that is the problem IMO)

_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray2[$i], "E:E")

 

Edited by Nine
Posted
  On 2/14/2022 at 2:21 PM, Nine said:

I am having a bit of hard time to follow your script.  But here are my thoughts (since this code is unrunable for me) :

1- remove those lines from the loop as they are repeating redundantly the same things

_Excel_SheetAdd($oWorkbook, -1, False, 1, "Test")
 Local $FileList = _FileListToArray("C:\Test\", "*.*")
_ArrayDisplay($aArray2)

2- You are writing a single value to the whole column (that is the problem IMO)

_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray2[$i], "E:E")

 

Expand  

Removing that did the trick @Nine Thanks all for your assistance 🙂

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...