0

I'm trying to add text in the current selected cell

My VBA function is :

Function AddText()
    ActiveCell.Value = "Hello World!"
End Function

But I'm getting following error when I call the function :

"There are one or more circular references where a formula refers to its own cell either directly or indirectly. This might cause them to calculate incorrectly. Try removing or changing these references, or moving the formulas to different cells."

Please help!

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Mistique
  • 47
  • 2
  • 6

1 Answers1

1

When using a function, you need to let the function return the value, not change the cell's value:

Function AddText()
    AddText = "Hello World!"
End Function

and then you can use it in a cell like so =AddText() which will show "Hello World!" in the cell you've typed it in.

BigBen
  • 46,229
  • 7
  • 24
  • 40
Notus_Panda
  • 1,402
  • 1
  • 3
  • 12