0

I'm trying to write a function in one cell, and then using that cell's address as a reference point, I'd like to change the value of a cell on Sheet2. Essentially, I'm attempting to make a function yield two different outputs, each output on a different sheet. Here's what I have so far:

Function test() As Variant
    Application.Caller.Worksheet.Cells(Application.Caller.Row,Application.Caller.Column).Row
    Application.Caller.Worksheet.Cells(Application.Caller.Row, Application.Caller.Column).Column
    Sheet2.Cells(a + 1, b + 1).Value = 8
End Function

The goal with this is to type "=TEST()" in cell A1 on Sheet1, and A1 would equal zero while cell B2 on Sheet2 would equal 8. I've heard rumors that Excel simply won't allow a UDF to affect change to any other cell other than the one in which it was written, but I really don't want to believe that rumor!

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

You can achieve your goal with a combination of a function (UDF) and an Event Macro.

The UDF would place a value in A1 and the event macro would detect this occurrence and change the cell on the other sheet.

Gary's Student
  • 95,722
  • 10
  • 59
  • 99