 | Distinguished Member with 2,640 posts. | | Join Date: Dec 2007 Location: HERE OR THERE?!?!?! Experience: Always Learning! | | Solved: Excel Macro -> Use LEFT Function with Paste Special Is there a way to use the LEFT Function with Paste Special? | | Distinguished Member with 9,342 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer | | You can use the left function before using the equivelent of paste special, but does it need to be a paste operation?
Are you "pasting" to more than one cell? | | Senior Member with 368 posts. | | Join Date: Dec 2008 Location: GMT 00.00 UK | | You want to write code to just copy the leftside of a cell? How a many characters?
Where is it to be pasted? - In place? | | Distinguished Member with 2,640 posts. | | Join Date: Dec 2007 Location: HERE OR THERE?!?!?! Experience: Always Learning! | | I apologize for not giving better details.
Here is what I am trying to accomplish.
I need to copy a range of cells H5:H23. I only want to take the first 5 characters. I then need to paste the cells in R5:R23. | | Senior Member with 368 posts. | | Join Date: Dec 2008 Location: GMT 00.00 UK | | try this Code:
Sub Macro2()
For x = 5 To 23
Cells(x, "R") = Left(Cells(x, "H"), 5)
Next
End Sub
| | Distinguished Member with 9,342 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer | | turbodante, nice code and not a "paste" in sight | | Distinguished Member with 2,640 posts. | | Join Date: Dec 2007 Location: HERE OR THERE?!?!?! Experience: Always Learning! | | Turbodante, very nice.
I have to perform this once more, but what if the cells where the values are going to be pasted are not the same?
For Example, the cells D5 D23 are to be copied and pasted to V25:V43. | | Distinguished Member with 9,342 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer | | Then you would use
Cells(x, "R") = Left(Cells(x+ 18, "H"), 5) | | Senior Member with 368 posts. | | Join Date: Dec 2008 Location: GMT 00.00 UK | | Quote:
Originally Posted by OBP Then you would use
Cells(x, "R") = Left(Cells(x+ 18, "H"), 5) |
perhaps OBP mean to say... Code: Sub Macro2()
For x = 5 To 23
Cells(x + 20, "V") = Left(Cells(x, "H"), 5)
Next
End Sub
..surely | | Distinguished Member with 9,342 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer |
30-Oct-2009, 10:53 AM
#10 | Yep, sorry about that, doing 2 things at once. | | Distinguished Member with 2,640 posts. | | Join Date: Dec 2007 Location: HERE OR THERE?!?!?! Experience: Always Learning! |
30-Oct-2009, 11:15 AM
#11 | I have one more scenerio. What if you want to paste this information on a different worksheet?
So, I want to copy data from H5:H23, only take the first five characters, and paste the valus in G32:G52
The reason for all the scenerios is I am still determining which way I plan to setup teh workbook.
__________________ Computerman29642
"I can do all things through Christ which strengtheneth me." (Philippians 4:13) | | Senior Member with 368 posts. | | Join Date: Dec 2008 Location: GMT 00.00 UK |
30-Oct-2009, 11:43 AM
#12 | If you want to paste to different sheets Code: Sheets("target").Cells(x + 27, "G") = Left(Sheets("Sheet1").Cells(x, "H"), 5)
In the above, I've called the sheet where it'll paste 'Target'.
[Though was OBP says, paste without pasting]
Last edited by turbodante : 30-Oct-2009 11:51 AM.
| | Distinguished Member with 2,640 posts. | | Join Date: Dec 2007 Location: HERE OR THERE?!?!?! Experience: Always Learning! |
30-Oct-2009, 12:10 PM
#13 | Thanks Turbodante. You have helped me so much. | | Distinguished Member with 2,640 posts. | | Join Date: Dec 2007 Location: HERE OR THERE?!?!?! Experience: Always Learning! |
30-Oct-2009, 01:41 PM
#14 | Thank you OBP as well. | | Distinguished Member with 4,511 posts. | | Join Date: Jul 2004 Location: Oregon, United States Experience: I'ma learnin'! |
30-Oct-2009, 08:51 PM
#15 | With the suggestion of an array, it would take out the need to loop through cells, which is generally less efficient than looping through an array. The other option is to use a range of cells and apply a formula to it all at once, use that range to copy at once, delete (clean up) and move as desired. Just more options. | |
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 04:23 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|