-1

I have the following macro, which takes a sparse set of data and copies the only entry from each row into the left-most column. Example of data

I am hoping someone could rewrite this macro into one that will work with the same data in LibreOffice.

Sub Macro1()

    Dim rng As Range

    Set rng = Selection


    For Each row In rng.Rows
        For Each cell In row.Cells
            If cell <> "" Then
                Debug.Print cell
                row.Cells(1) = cell
            End If
        Next
    Next

End Sub

Example of data

    enter image description here

Jon Friedman
  • 64
  • 1
  • 10
  • 3
    I would humbly suggest you make an attempt at converting the code yourself and return to edit your question with your original effort if you run into problems. –  Jan 12 '16 at 19:34
  • 1
    This is not a code porting service, where you dump code and the new language desired and someone does the work for you. Make an effort to port it yourself. If you run into problems, you can then post a question asking about the problem you've encountered, include your code, and ask a **specific** question about that problem. Good luck. – Ken White Jan 12 '16 at 19:39
  • I would ordinarily never ask someone to convert code for me, but since this is a one-off task utilizing a skill set (LO Basic) I'm not really interested in learning in-depth, and a whopping 10 lines of code, I thought I could pose it to the community. If I go down the rabbit hole of learning the same exact skill set I have in VBA for this one-off task i'm wasting time. If someone already has this skill set and can convert 10 lines of code I wrote or accomplish the same for a best answer, then both of us will benefit. Otherwise my next q will be "How do I turn the selection into a variable"Yawn – Jon Friedman Jan 12 '16 at 21:17
  • @steve-zhan I saw that you answered a similar question about looping in http://stackoverflow.com/questions/14724193 – Jon Friedman Jan 14 '16 at 18:21

1 Answers1

1

Have a look at Andrew Pitonyak's macro document. Section 6 is the area that deals with Calc macros.

  • Get the selected rows with code similar to section 6.9 Fill selected range with text.
  • Also use code similar to section 6.14 Display all data in a column.
Jim K
  • 12,824
  • 2
  • 22
  • 51
  • Thank you very much for the link. I'm browsing the document and I'm going to try to piece something together from these snippets. – Jon Friedman Jan 12 '16 at 21:20