I have to following code:
How can I accomplish this?![]()
Please Login or Register to view this content.
I have to following code:
How can I accomplish this?![]()
Please Login or Register to view this content.
Last edited by Cutter; 07-20-2012 at 11:44 AM. Reason: Added code tags
why are you using a loop here?
you can accomplish the same with this
![]()
Please Login or Register to view this content.
I do not want to copy the range C41:F57 as a chunk. I want to copy as chunks of 4 cells a row at a time. That is copy C40:F40 and paste it to C26:F26. Then run some calculation on C26:F26 (unrelated to this discussion). Then I want to repeat this sequence on C41:F41 copy and paste to C26:F26. Then do the same for C42:F42 upto C57:F57.
So I basically need a loop to copy and paste 4 cells each and go down to the next row and repeat it 17 times.
See if this works for you
![]()
Please Login or Register to view this content.
fredlo2010, This is great. It worked.
What if I need to just copy 1 cell (NOT a range) with the cell being a variable (just like you did it - say from cells(i, 7) to cells(i, 8) ).
But the copy from cells(i, 7) needs to be a paste special to cells(i, 8)
I tried this:
Here I am trying to copy from B34 and B35 to G47 and H47 and repeat the same through rows 48 to 57.![]()
Please Login or Register to view this content.
This code does not work. It copies B34,B35 through range G47:H57?
Also I need this to be paste special.
Thanks
Last edited by Cutter; 07-20-2012 at 11:44 AM. Reason: Added code tags
I am not following you man.
Can you give me a sample of your workbook. Also you can go through the code by pressing "F8" it will go lineby line, so you can see what the code is doing.
I have a range of data C40:F57.
I need to copy C40:F40 to C26:F26, run some calculations and copy cell B34 and B35 and paste special to G40:H40.
Your code above let me copy C40:F40 to C26:F26 and then repeat the copy steps for C41:F57. How do I accomplish:
Copy cell B34 and B35 and paste special (values) to G40:H40. Note this needs to be a loop too same loop where paste special needs to go to the range
G40:H57. First paste special will be to G40:H40, then to G41:H41 and go to G57:H57.
Code I have so far is:
![]()
Please Login or Register to view this content.
Last edited by Cutter; 07-20-2012 at 11:45 AM. Reason: Added code tags
You are resizing when there is no need to. You are copying only one cell. Ex
If you want to copy range "A1:B2" then you pic the start and resize it. Range("A1").resize(0,2) which is a little ambiguous.
So here is the code take a look and tell me if it works. I modified it to match the Values only.
![]()
Please Login or Register to view this content.
fredlo2010
Code:
Didnt work as expected. It not only copies B34 and B35 to G40 and H40 but goes through G40:H57 and copies to the whole range.![]()
Please Login or Register to view this content.
Not sure how the loop from 40 to 57 interferes here. Every time it goes through the loop, B34:35 are overwritten through out the range
G40:H57 and NOT just its respective row cells.
Thanks
Last edited by Cutter; 07-20-2012 at 11:45 AM. Reason: Added code tags
@ Mannyny
Welcome to the forum.
Please notice that code tags have been added to your post(s). The forum rules (Rule #3) require them so please keep that in mind and add them yourself whenever showing code in any of your future posts.
Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks