Jump to content

excel fill in


yton
 Share

Recommended Posts

Greetings,

I use StringSplit to split the array and paste data in excel

$array = StringSplit(ClipGet(), "ZZZ", 1)
_WordQuit($oWordapp, 0)
$oExcel = _ExcelBookOpen("Z:\_script\content.csv")
_ExcelSheetActivate($oExcel, "content")
For $i = 1 To $array[0] ;Loop
    _ExcelWriteCell($oExcel, $array[$i], $i, 15)
Next

I have a question:

say, what if the array returns only 10 (20, 30 whatever but < 50) strings - each has to be filled in the corresponding cell in a certain column of a datasheet - and I need to fill in 50 cells? I mean I can even duplicate strings, but 50 cells must be filled in.

what function or loop should I pay attention to in this case?

thank you,

Link to comment
Share on other sites

As I read that (not very clear) description, you mean to fill in rows from $array[0] + 1 to 50 with a default value? So:

For $i = 1 To $array[0] ;Loop
    _ExcelWriteCell($oExcel, $array[$i], $i, 15)
Next

For $i = $array[0] + 1 to 50
    _ExcelWriteCell($oExcel, "<Default Value>", $i, 15)
Next

:idea:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well if you're only doing this on ONE array, you could do the following.

$arrSplitResults = StringSplit(ClipGet(), "ZZZ", 1)
_WordQuit($oWordapp, 0)
$oExcel = _ExcelBookOpen("Z:\_script\content.csv")
_ExcelSheetActivate($oExcel, "content")

     For $x = 0 to Ubound($arrWhatEversIsHoldingYourData) - 1

       _ExcelWriteCell($oExcel, $arrSplitResults[$i], 1, $x)   

     Next

That would fill in row 1 of your spreadsheet for as many as there are elements in your array.

But I'm guess you really going to use an array of arrays. Like this.

$arrWhatever = _ExcelReadSheetToArray($oExcel)

     For $x = 1 to Ubound($arrWhatever) - 1

          $arrSplit = StringSplit($arrWhatever[$x][1], "ZZZ", 1)

          For $y = 1 to Ubound($arrSplit) - 1

               _ExcelWriteCell($oExcel,$arrSplit[$y],$x,$y)

          Next

     Next
Link to comment
Share on other sites

As I read that (not very clear) description, you mean to fill in rows from $array[0] + 1 to 50 with a default value? So:

For $i = 1 To $array[0] ;Loop
    _ExcelWriteCell($oExcel, $array[$i], $i, 15)
Next

For $i = $array[0] + 1 to 50
    _ExcelWriteCell($oExcel, "<Default Value>", $i, 15)
Next

:idea:

I agree with PsaltyDS, the description needs to be a bit clearer, but I'm sure between the two us, your questions should've been answered.
Link to comment
Share on other sites

I agree with PsaltyDS, the description needs to be a bit clearer, but I'm sure between the two us, your questions should've been answered.

thank you very much.

my question is 100% answered

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...