Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default 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.







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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.











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.











  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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.









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.











  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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.




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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.








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
Write formula for simple copy and paste to another cell Kalffiend Excel Worksheet Functions 1 January 12th 10 09:10 PM
Line copy - Not just a simple copy paste Ninerref Excel Worksheet Functions 3 September 10th 09 11:44 AM
Simple Copy & Paste Bob Barnes[_3_] Excel Programming 3 February 20th 04 11:09 PM
Simple copy paste question Z[_2_] Excel Programming 3 February 5th 04 09:03 PM
Simple copy and paste Fritz[_2_] Excel Programming 2 November 22nd 03 01:56 PM


All times are GMT +1. The time now is 01:18 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"