![]() |
simple cell copy using VBA
I get the error #VALUE! as a result of the following VB code Cells(2, 2) =
Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
Give this a try.
Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
where is the entry
in your case try cells(2,25)=cells(2,2) does it help? cells(2,2) has already data and cells(2,25) is blank so you configure that cells(2,25) willhave the value of cells(2,2) Bob Taylor wrote in message ... I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
Devin
thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
Bob:
You have written a procedure and enclosed it with FUNCTION() ' a different breed of cat.. Replace (in a Standard module) with: Sub MV() Range("B2").ClearContents ' or cells(2,2).ClearContents Cells(2, 2) = Cells(2, 25) End Sub HTH "Bob Taylor" wrote in message ... Devin thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
Jim
my understanding of the difference between a function and a subprocedures is that the function returns a value and the sub doe not. i recoded the function to a sub and as i step through the sub, the range.clearcontents does not clear the content and then the range().value = range().value does not copy the data. the assignment statement should work in either wrappers without error. i am still looking for the root of the problem thanks bob "Jim May" wrote in message news:VoXwd.6771$jn.6741@lakeread06... Bob: You have written a procedure and enclosed it with FUNCTION() ' a different breed of cat.. Replace (in a Standard module) with: Sub MV() Range("B2").ClearContents ' or cells(2,2).ClearContents Cells(2, 2) = Cells(2, 25) End Sub HTH "Bob Taylor" wrote in message ... Devin thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
it does not make any difference.
thanks though "R.VENKATARAMAN" &&& wrote in message ... where is the entry in your case try cells(2,25)=cells(2,2) does it help? cells(2,2) has already data and cells(2,25) is blank so you configure that cells(2,25) willhave the value of cells(2,2) Bob Taylor wrote in message ... I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
i just put an on error handler in and found Err.Number = 1004. where do you
find out what the 1004 really means. thanks "Jim May" wrote in message news:VoXwd.6771$jn.6741@lakeread06... Bob: You have written a procedure and enclosed it with FUNCTION() ' a different breed of cat.. Replace (in a Standard module) with: Sub MV() Range("B2").ClearContents ' or cells(2,2).ClearContents Cells(2, 2) = Cells(2, 25) End Sub HTH "Bob Taylor" wrote in message ... Devin thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
A function called from a worksheet cell can not change the excel environment
or change the value of other cells. It can only return a value to the cell in which it is located (just like builtin functions). -- Regards, Tom Ogilvy "Bob Taylor" wrote in message ... Jim my understanding of the difference between a function and a subprocedures is that the function returns a value and the sub doe not. i recoded the function to a sub and as i step through the sub, the range.clearcontents does not clear the content and then the range().value = range().value does not copy the data. the assignment statement should work in either wrappers without error. i am still looking for the root of the problem thanks bob "Jim May" wrote in message news:VoXwd.6771$jn.6741@lakeread06... Bob: You have written a procedure and enclosed it with FUNCTION() ' a different breed of cat.. Replace (in a Standard module) with: Sub MV() Range("B2").ClearContents ' or cells(2,2).ClearContents Cells(2, 2) = Cells(2, 25) End Sub HTH "Bob Taylor" wrote in message ... Devin thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
Tom
is there any way of changing other cell value. this is explaining to me what the root of the problem is thanks bob "Tom Ogilvy" wrote in message ... A function called from a worksheet cell can not change the excel environment or change the value of other cells. It can only return a value to the cell in which it is located (just like builtin functions). -- Regards, Tom Ogilvy "Bob Taylor" wrote in message ... Jim my understanding of the difference between a function and a subprocedures is that the function returns a value and the sub doe not. i recoded the function to a sub and as i step through the sub, the range.clearcontents does not clear the content and then the range().value = range().value does not copy the data. the assignment statement should work in either wrappers without error. i am still looking for the root of the problem thanks bob "Jim May" wrote in message news:VoXwd.6771$jn.6741@lakeread06... Bob: You have written a procedure and enclosed it with FUNCTION() ' a different breed of cat.. Replace (in a Standard module) with: Sub MV() Range("B2").ClearContents ' or cells(2,2).ClearContents Cells(2, 2) = Cells(2, 25) End Sub HTH "Bob Taylor" wrote in message ... Devin thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
No. It isn't allowed by Excel.
You might want to use the Change, SelectionChange or Calculate events to accomplish your purpose. http://www.cpearson.com/excel/events.htm Chip Pearson's page on events -- Regards, Tom Ogilvy "Bob Taylor" wrote in message ... Tom is there any way of changing other cell value. this is explaining to me what the root of the problem is thanks bob "Tom Ogilvy" wrote in message ... A function called from a worksheet cell can not change the excel environment or change the value of other cells. It can only return a value to the cell in which it is located (just like builtin functions). -- Regards, Tom Ogilvy "Bob Taylor" wrote in message ... Jim my understanding of the difference between a function and a subprocedures is that the function returns a value and the sub doe not. i recoded the function to a sub and as i step through the sub, the range.clearcontents does not clear the content and then the range().value = range().value does not copy the data. the assignment statement should work in either wrappers without error. i am still looking for the root of the problem thanks bob "Jim May" wrote in message news:VoXwd.6771$jn.6741@lakeread06... Bob: You have written a procedure and enclosed it with FUNCTION() ' a different breed of cat.. Replace (in a Standard module) with: Sub MV() Range("B2").ClearContents ' or cells(2,2).ClearContents Cells(2, 2) = Cells(2, 25) End Sub HTH "Bob Taylor" wrote in message ... Devin thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
simple cell copy using VBA
1004 is a general error. More important is the descriiption provided with
the 1004 error. But as stated, what you are trying to do is not allowed in a User defined function used in a worksheet. -- Regards, Tom Ogilvy "Bob Taylor" wrote in message ... i just put an on error handler in and found Err.Number = 1004. where do you find out what the 1004 really means. thanks "Jim May" wrote in message news:VoXwd.6771$jn.6741@lakeread06... Bob: You have written a procedure and enclosed it with FUNCTION() ' a different breed of cat.. Replace (in a Standard module) with: Sub MV() Range("B2").ClearContents ' or cells(2,2).ClearContents Cells(2, 2) = Cells(2, 25) End Sub HTH "Bob Taylor" wrote in message ... Devin thanks for the info.. i had tried this and it failed. i recode it as Function MV() On Error GoTo bob Range("B3").ClearContents Range("B3").Value = Range("Y3").Value 'Cells(2, 2) = Cells(2, 25) bob: ' MsgBox " cannot store in old values" End Function it fails again. when i run with a stop on, and watch the cells it fails on first pass. however if i step into it again it works. i don't understand what is going on. bob "DMoney" wrote in message ... Give this a try. Range("B2").value = Range("B25").Value Devin "Bob Taylor" wrote: I get the error #VALUE! as a result of the following VB code Cells(2, 2) = Cells(2, 25). according to the examples and the books this should work and is very easy, but i can not make it work, the cell types are both GENERAL and the contents are strings. i have tried string to string and using ranges and everything else that i can find and nothing allows me to move the contents of one cell to another. it has to be a simple answer. |
All times are GMT +1. The time now is 12:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com