How to create a macro that reads a cell and outputs data to a different cell?

Hey guys, I cant seem figure out how to make a macro that reads the data of a particular cell, and then display it on another cell.

I’m a salesman and the macro would be used to help me keep track of my weekly sales. It would read a cell which contained the number of sales in a week, and then display it that number in another cell. My ultimate goal is to be able to create a dropdown to select any week and see the total sales and earning of that week. Depending on what week I select, it would display a different number in the output cells. Thanks :slight_smile:

From the description, it does not sound like macros are needed. That’s good because simpler solutions are easier to maintain and less can go wrong.

For the dropdown box (cell A1 below), go to Data → Validity and use a cell selection. The formula to display the result of the dropdown box uses a lookup formula (cell A2 below). Documentation: HLOOKUP.

=HLOOKUP(A2;D1:F6;6)

lookup table example

The file: lookup example.ods

Wow that is muuuuuuch easier. I managed to do it with a macro and while it works, its a little sloppy because i have multiple entries. (1,33) is the cell it reads, and (6,6) is the output cell.

	'Total sales
TotalSales = sheet.getCellByPosition(1, 33).String
sheet.getCellByPosition(6,6).String = TotalSales

Thanks for your helpful and timely reply