View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Taylor Bob Taylor is offline
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.