Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selection.Copy ????

Status
Not open for further replies.

Mungovan

Programmer
Oct 24, 2002
94
IE
Hi!
This is really a VB question in Excel, but I hope someone can still help me???

Basically I have some code that copies the contents of cell E1 in Sheet B, and then pastes that numerical value to cell B1 in Sheet A.

The trouble is that I'm copying a cell that is a sum of other cells i.e Cell E1 in Sheet B is =Sum(A1:A4).

So I get errors when I try to copy that value. The computer can't seem to copy a value that is derived from a formlae???

What can I do???

Thanks a mill,
D
 
try this instead of copying


sheets("sheetA").range("b1")=sheets("sheetB").range("E1")
 
Hi - use:
selection.PasteSpecial Operation:=xlPasteValues

HTH
~Geoff~
[noevil]
 
Hi,
Well, the problem really isn't in the pasting, it's in the selecting

Even when I try to just select the cell I get an error.


P.s. - I had previously done that paste special in my code, but I can't even copy the data in order to paste!!!

Thanks again for any help????
D
 
What error are you getting when you try to select the cell using VBA?

You shouldn't use cell(x,y).select when you're copying and pasting anyway, not unless processing time is of no consequence to you.

Personally I;d use ETID's assignment statement.
 
If you wanna go down that route, shouldn't you explicitly tell excel which bit of the cell you are using ie value / formula / text....
sheets("sheetA").range("b1").value = sheets("sheetB").range("E1").value

HTH
~Geoff~
[noevil]
 
Geoff, Value is the default property of the range object.

You have to be careful if you start setting user-defined ranges as well though ... in fact in that event I would start actually specifying .Value after the range in my assignment statements.
 
cool - think I'll carry on specifying tho - even if it's just for my clarity
Thx Bry HTH
~Geoff~
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top