Search code examples
excellibreoffice-calcvba

How do I create a macro that changes the cell displayed by pressing the button?


Example. In cell B1 display the contents of cell A1. And by pressing the button I wish to cell B1 displays the value of cell A2, and press the button again I wish to cell B1 displays the contents of cell A3 and so to cell A100. Can someone help me? This is possible?


Solution

  • Try assigning below code to button

    Sub DISPLAY_CELLS()
        Range("C1") = (Range("C1") mod 100) + 1
        Range("B1") = Range("A" & Range("C1"))
    End Sub
    

    This will move you down to 100th data everytime you click button

    THen start over when it reaches 100th data

    Range("C1") is used to find Nth data.