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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Insert Rows in a script for the whole worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

elnino

20 Posts

Posted - 10/17/2016 :  5:57:02 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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 !(=

cpyang

USA
1406 Posts

Posted - 10/17/2016 :  8:29:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
wks.InsertRows(2)

You have 's' missing.

CP
Go to Top of Page

elnino

20 Posts

Posted - 10/18/2016 :  07:11:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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?

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000