One of the very first ideas we had for this blog was to convert some of the wonderful gems of the early era of our site, the undisciplined period, to blog posts. Questions that were once enthusiastically received by the community, but no longer fit Programmer’s scope. The first deleted question I’ve chosen is Jon Skeet’s “What’s your most controversial programming opinion?” question (available only to 10K+ users, sorry), a +391 scored question that was originally asked on Stack Overflow on January 2, 2009. What follows are twenty of the highest voted answers, in random order…
This macro will duplicate values in column A & B according to the value specified in column C. The results will be generated in columns D & E. The first row is the header. The macro is assigned to a button (named Push in this case). This macro works only in LibreOffice Calc and uses LibreOffice Basic Sample Data before running the Macro The Macro: Sub DuplicateRowsAsPerValue() Dim i As Double Dim j As Double Dim z As Double Dim w As Double sheet = ThisComponent.getSheets().getByIndex(0) For i = 0 To 10000 j = sheet.getCellByPosition(2, i).Value For z = 1 To j + 1 sheet.getCellByPosition(3, z + w).String = sheet.getCellByPosition(0, i).String sheet.getCellByPosition(4, z + w).String = sheet.getCellByPosition(1, i).String Next z w = w + z - 2 Next i End Sub The Macro (Adapted to run on LibreOffice Calc) Assign the Macro to a Button (in this case the the green one named Push) Duplicated values in columns D & E as per values in column C...
Comments
Post a Comment