Need help with a Calc formula

I have a Calc document with two sheets. I need it to take the value of cell Ax on Sheet2, total up the values in column B on Sheet1 where the corresponding value of the cell in column G equals that of cell Ax on Sheet2, and put that sum in cell Bx on Sheet2. Is this possible? Sorry if I’m not explaining this well.

Assuming A2 for Ax and B2 for Bx, enter this formula into B2; also assuming row ranges 2 to 99 for columns, adapt as necessary.

=SUMIF($Sheet1.G$2:G$99;$Sheet2.A2;$Sheet1.B$2:B$99)

You can then copy&paste or pull down this formula cell to B3,B4,B5,… and the reference $Sheet2.A2 will be adjusted to $Sheet2.A3, $Sheet2.A4, $Sheet2.A5, … while the other row references are absolute (prefixed with $) and stay the same.

Works great! Thanks so much!