Re: Writing values to cells



Thanks for your help. So, is there any way of writing a value to a cell (in
a UDF) that is not adjacent to the cell where the function is called?
Thanks;

Bob

"Gary''s Student" <GarysStudent@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:84BB5B5E-9AD8-4683-95C7-3C46FF2BC660@xxxxxxxxxxxxxxxx
With some very rare exceptions, VBA functions can only return a value to
the
cell in which the function resides.

1. It can cause other cells to change only with the help of a "helper"
macro
2. It can't change the format of cells
3. It CAN insert or change comments
4. It can return values to several adjacent cells if the UDF returns an
array.
--
Gary''s Student - gsnu200771


"Bob" wrote:

Hi everyone:

Does anyone know why in VBA for excel, why I cannot write a value to a
cell
in a function, but I can in a sub without arguments? Is this a bug? For
example;

Public Function w(x As Double) As Double
Range("A1").Value = x
End Function

does not work. Whereas;

Public Sub w()
Range("A1").Value = 3.23
End Sub

Does work.

So, inside a function, how can I write to a cell? I appreciate your
help.

Bob





.



Relevant Pages

  • Re: Compound IF statement
    ... Thank you, Otto. ... The second bit of code is a UDF. ... Sub CountsBACD() ... If Col 1 has BA and if the same cell in Col 2 has DC, ...
    (microsoft.public.excel.programming)
  • RE: Macro Suddenly Stopped Working
    ... macro tries to paste to a locked cell you will get a runtime error. ... The macro suddenly stopped working and the user that created it is no ... Sub NormalizeData() ... Public Function CellFunction ...
    (microsoft.public.excel.programming)
  • Re: Compound IF statement
    ... Thank you, Otto. ... The second bit of code is a UDF. ... Sub CountsBACD() ... If Col 1 has BA and if the same cell in Col 2 has DC, ...
    (microsoft.public.excel.programming)
  • Re: Found a glitch in the OFFSET function.
    ... cause Excel to ignore the dirty-flag. ... properties to determine whether it should recalculate a given cell. ... yet dogmatic view that your UDF was a superior alternative to Excel's ... "Peter T" wrote: ...
    (microsoft.public.excel.programming)
  • Re: Compound IF statement
    ... Dim TheRng As Range ... "Otto Moehrbach" wrote: ... The second bit of code is a UDF. ... If Col 1 has BA and if the same cell in Col 2 has DC, ...
    (microsoft.public.excel.programming)