The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 Insert Rows in a script for the whole worksheet

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
elnino Posted - 10/17/2016 : 5:57:02 PM
Hello

I want to insert rows in a script for many cells of a worksheet. I made a column for comparison, and if the comparison doesnt fit with the data there should insert rows in all cells, except the comparison cells.

i tried it with a complex script, but no Change was seeing. Then I tried it with simple scripts as

wks.insertRow(2)

or:

wks.insertRow(2,1,4)


But there didnt happened anything again.


Should I have to write the script in another way? Or where could be the Problem?

I hope somebody can help me !(=

2   L A T E S T    R E P L I E S    (Newest First)
elnino Posted - 10/18/2016 : 07:11:44 AM
Hi cpyang!

Thank you very much for Reply and helping me! With 's' the small script works.

But the more complex script doesnt work.

example:

int hour, day, month, year; int hourIndex = 4; int dayIndex = 5; int monthIndex = 6; int yearIndex = 7; int expectedDay, expectedMonth, expectedYear; int expectedHour = 0; int c1 = 1; int c2 = 2; int c3 = 3; int rowIndexForCompareDate = 1; int i = 0; while (i < wks.nRows) { i++; hour = wcol(hourIndex)[i]; day = wcol(dayIndex)[i]; month = wcol(monthIndex)[i]; year = wcol(yearIndex)[i]; expectedDay = wcol(c1)[rowIndexForCompareDate]; expectedMonth = wcol(c2)[rowIndexForCompareDate]; expectedYear = wcol(c3)[rowIndexForCompareDate]; if (day != expectedDay || month != expectedMonth || year != expectedYear || hour != expectedHour) { wks.insertRows(i;1;4); wcol(hourIndex)[i] = expectedHour; wcol(dayIndex)[i] = expectedDay; wcol(monthIndex)[i] = expectedMonth; wcol(yearIndex)[i] = expectedYear; } if (expectedHour == 23) { rowIndexForCompareDate++; expectedHour = 0; } else expectedHour++; }


example 2:

int hour; int day; int month; int year; int hourIndex = 4; int dayIndex = 5; int monthIndex = 6; int yearIndex = 7; int expectedDay; int expectedMonth; int expectedYear; int expectedHour = 0; int c1 = 1; int c2 = 2; int c3 = 3; int rowIndexForCompareDate = 1; int i = 0; while (i < wks.nRows) { i++; hour = wcol(hourIndex)[i]; day = wcol(dayIndex)[i]; month = wcol(monthIndex)[i]; year = wcol(yearIndex)[i]; expectedDay = wcol(c1)[rowIndexForCompareDate]; expectedMonth = wcol(c2)[rowIndexForCompareDate]; expectedYear = wcol(c3)[rowIndexForCompareDate]; if (day != expectedDay || month != expectedMonth || year != expectedYear || hour != expectedHour) { wks.insertRows(i;1;4); wcol(hourIndex)[i] = expectedHour; wcol(dayIndex)[i] = expectedDay; wcol(monthIndex)[i] = expectedMonth; wcol(yearIndex)[i] = expectedYear; } if (expectedHour == 23) { rowIndexForCompareDate++; expectedHour = 0; } else { expectedHour++; } }

Do you have any idea where the mistake is? Or does somebody else know more?

cpyang Posted - 10/17/2016 : 8:29:08 PM
wks.InsertRows(2)

You have 's' missing.

CP

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000