View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul Lautman Paul Lautman is offline
external usenet poster
 
Posts: 85
Default Problem with function creation

terminator_ba wrote:
Please help me, my question is the following:
How can i create a function in Excel/VBA which copy the value in a
cell that is not the cell in which the function is executed and paste
this value in another cell?

I tried the following:

function transfer(cell1,cell2)
range("cell1").select
selection.copy
range("cell2").select
activesheet.paste
end function

But i got no success, please help me


The problem with this is that the function would not know when it was
supposed to do this.

If cell1 was A1 and cell2 was B2 then you could just put =A1 in B2

Or you could change the function to a sub like this:

sub transfer(cell1,cell2)
range(cell2).value = range(cell1).value
end sub