Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with function creation


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


--
terminator_ba
------------------------------------------------------------------------
terminator_ba's Profile: http://www.excelforum.com/member.php...o&userid=35511
View this thread: http://www.excelforum.com/showthread...hreadid=552826

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with function creation


i will try to be clear, i want to copy the value in A1 and paste it in
B1 ONLY if a condition is true. If this condition is true, the value of
A1 is copied into B1 , but if the condition is false, it doesnt happen
anything, the value in B1 is kept. Well I tried to insert the following
function in B1: =If(c1<0;a1) but it returns a False in B1 cell if the
condition is false. I want it to return a value only if the condition
is true, and if the condition is false, it keeps the old value. Its
like a register do you understand?


--
terminator_ba
------------------------------------------------------------------------
terminator_ba's Profile: http://www.excelforum.com/member.php...o&userid=35511
View this thread: http://www.excelforum.com/showthread...hreadid=552826

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default Problem with function creation

terminator_ba wrote:
i will try to be clear, i want to copy the value in A1 and paste it in
B1 ONLY if a condition is true. If this condition is true, the value
of A1 is copied into B1 , but if the condition is false, it doesnt
happen anything, the value in B1 is kept. Well I tried to insert the
following function in B1: =If(c1<0;a1) but it returns a False in B1
cell if the condition is false. I want it to return a value only if
the condition is true, and if the condition is false, it keeps the
old value. Its like a register do you understand?


How's about something like:

in B1: =IF(C1<0;A1;'value you want in b1')


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Problem with function creation

G'day there Peepuls,

[This followup was posted to microsoft.public.excel.programming and a
copy was sent to the cited author.]

in B1: =IF(C1<0;A1;'value you want in b1')


I think that should be "=IF(C1<0, A1, 'value you want it b1')".
Commas, not semi-colons. (Paul I think you typed too fast <g)

See ya
Ken McLennan
Qld, Australia


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default Problem with function creation

Ken McLennan wrote:
G'day there Peepuls,

[This followup was posted to microsoft.public.excel.programming and a
copy was sent to the cited author.]

in B1: =IF(C1<0;A1;'value you want in b1')


I think that should be "=IF(C1<0, A1, 'value you want it b1')".
Commas, not semi-colons. (Paul I think you typed too fast <g)

See ya
Ken McLennan
Qld, Australia


No, I copied what the OP had used thus:
"...Well I tried to insert the following function in B1: =If(c1<0;a1) but
it returns..."


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Creation via Add-in problem Bill Schanks Excel Programming 1 February 10th 06 12:02 AM
Problem with chart creation. daniel chen Charts and Charting in Excel 3 January 11th 06 04:00 AM
Problem with chart creation daniel chen Excel Discussion (Misc queries) 2 January 8th 06 06:27 PM
Ultimate circular problem for chart creation nick g Excel Discussion (Misc queries) 1 July 26th 05 01:18 PM
Automatic Number Creation Problem? Corp Excel Worksheet Functions 1 April 6th 05 06:19 AM


All times are GMT +1. The time now is 06:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"