+ Reply to Thread
Results 1 to 16 of 16

copy & paste macro not working

  1. #1
    Registered User
    Join Date
    04-28-2016
    Location
    usa
    MS-Off Ver
    2007
    Posts
    48

    copy & paste macro not working

    Dear Guys:

    I have this code and it is not working as I need

    Please Login or Register  to view this content.
    the problem is that I select a row where I want to start the first step of the above code and start pasting the data in column c and the selected raw number

    the problem occurred in step 2 of the code where I tried to copy another range of data rom Column a to column b in destination and needed it to start pasting data in column b in the same raw number I selected at the beginning.

    the reason I am trying to do this, because there are columns in the range that I do not need to be copied and pasted, and I want to be able to dynamically use the macro that is why I need the code to recognize the raw number in my first selection

    it works very well without adding the second step in the code

    thank you in advance
    Last edited by markswan111; 04-24-2023 at 12:41 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: copy & paste macro not working

    What does it do that is different than what you want it to do?

    Although I would not code using Windows().Activate, it appears that your code should work.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: copy & paste macro not working

    It looks like a concise explanation of what you want to accomplish would be easier.
    Experience trumps academics every day of the week and twice on Sunday.

  4. #4
    Registered User
    Join Date
    04-28-2016
    Location
    usa
    MS-Off Ver
    2007
    Posts
    48

    Re: copy & paste macro not working

    it is not running at all, giving this highlighted in yellow when debugging
    Range("C" & startRow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

  5. #5
    Registered User
    Join Date
    04-28-2016
    Location
    usa
    MS-Off Ver
    2007
    Posts
    48

    Re: copy & paste macro not working

    I have given more than a concise explanation in the very first post. please either try to help or if you can not you can just ignore my post, and let others willing to seriously help focus on it..no need for useless comments and suggestions "It looks like a concise explanation of what you want to accomplish would be easier."

    we are trying to help each others in this community

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: copy & paste macro not working

    No problem. Have it your way.
    BTW. It should not run at all.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: copy & paste macro not working

    Quote Originally Posted by markswan111 View Post
    it is not running at all, giving this highlighted in yellow when debugging
    Range("C" & startRow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    What is the error message you get when this occurs? When asking about a VBA error it is essential to give us the error number and error message.

    Also you originally said,
    the problem occurred in step 2 of the code where I tried to copy another range of data rom Column a to column b
    I do not know what you mean by "step 2" but the code above where you said you got an error is not copying from column A to B. It's C to C.

    Also, the way your code is written it is not possible for me to simply paste it into a file and run it. It is dependent on specific file names so I would either have to set up files with those names or rework the code to make it more generic. Hopefully we can resolve it on your end.

  8. #8
    Registered User
    Join Date
    04-28-2016
    Location
    usa
    MS-Off Ver
    2007
    Posts
    48

    Re: copy & paste macro not working

    Dear 6string,

    thank you for your help, I will upload two simple files that I am trying to do the above codes on.

    the first workbook book1 is the destination file and the second workbook is the source file book2

    step1- I need the vba to copy every other sell in range A163:A430 in book2, and paste the values starting with any selected cell in column B in book1

    step2- I need the vba to copy range c163:g430 from book2, and paste the values in column P of book1 starting with the same selected row number in step1

    step3- I need the vba to copy every other sell I163:I430 in book2, and paste the values in column W of book1 starting with the same selected row number in step1

    I am attaching both workbooks

    note: I don not need anything else copied or pasted, meaning the vba will only paste values in those columns starting with the same raw number of the
    selected cell row number in step1

    again thank you very much for your help
    Attached Files Attached Files

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: copy & paste macro not working

    Quote Originally Posted by markswan111 View Post
    step1- I need the vba to copy every other sell in range A163:A430 in book2, and paste the values starting with any selected cell in column B in book1

    step2- I need the vba to copy range c163:g430 from book2, and paste the values in column P of book1 starting with the same selected row number in step1

    step3- I need the vba to copy every other sell I163:I430 in book2, and paste the values in column W of book1 starting with the same selected row number in step1
    Your original post did not say that you want to copy every other cell, and that is not what your code does. Please clarify what you want to do here.

    Your original post did not mention anything about what you describe here as "step3".

    You have not told me what error code and message you get on that line of code you described in post #4.

    Of the two files you attached, which one is 1.xlsb and which one is ODELIS220233.xlsb?

  10. #10
    Registered User
    Join Date
    04-28-2016
    Location
    usa
    MS-Off Ver
    2007
    Posts
    48

    Re: copy & paste macro not working

    Dear Sir,

    in my first post I posted a vba and was planning to add other steps to it after I get an answer, then I thought it is safer and better to re do everything and ask for help with what I want done all together and I made clean files and posted them for you in my last post.

    so what I want is exactly what is posted in my last post, even the workbooks names are all correct and updated

    so in summary we can discard everything I posted and just refer to the very last post with the 2 files in it

    again thank you so much and sorry for the confusion

  11. #11
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: copy & paste macro not working

    Quote Originally Posted by markswan111 View Post
    we can discard everything I posted and just refer to the very last post
    Which is why we ask for a concise explanation of what you need.

    The code needs an extensive rewrite to copy and paste every other cell. I will see when I can do this.

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: copy & paste macro not working

    Hi Jeff.
    Re: "Which is why we ask for a concise explanation of what you need."
    You know the answer to that. It's in Post #5.

  13. #13
    Registered User
    Join Date
    04-28-2016
    Location
    usa
    MS-Off Ver
    2007
    Posts
    48

    Re: copy & paste macro not working

    Dear 6string,
    thank you much for your help, I do not want to trouble you in rewriting, I will try to do it myself and I will post the code here and ask you with concise explanation if I need anything....
    again you are much appreciated as you are the only one here who really tried to help and be patient with an open heart ,again thank you, and you are much appreciated....

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: copy & paste macro not working

    I guess you missed the point totally. If I made you feel bad, that was not my intention. My point solely is to make people see that they can't be helped if they are not willing to help themselves.

  15. #15
    Registered User
    Join Date
    04-28-2016
    Location
    usa
    MS-Off Ver
    2007
    Posts
    48

    Re: copy & paste macro not working

    For the benefit of all forum members, here is the vba code that could do all that I had wanted, I have created it myself, jolivanes, maybe you can learn that it is big mistake to make things seem harder for people, you frustrated me and made me think it is impossible code to be made, thank you anyway, hope you can be more flexible with forum members needing help, and if you can not help, just do not make things harder for them......


    Please Login or Register  to view this content.

  16. #16
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: copy & paste macro not working

    Quote Originally Posted by markswan111 View Post
    here is the vba code that could do all that I had wanted
    Thank you for sharing your solution.
    step3- I need the vba to copy every other sell I163:I430 in book2, and paste the values in column W of book1 starting with the same selected row number in step1
    This code does not do this.

    jolivanes simply suggested that you provide a better explanation than what was in your first post, which you later said to ignore. I would request that all parties stop further personal comments or the thread will be closed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Macro to copy/paste and mail some data, but it's not working!
    By nitozinho in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2016, 10:51 AM
  2. Copy and paste special macro not working
    By AndyF19 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2016, 11:37 AM
  3. Excel Copy and Paste Macro not working
    By LewisLonsdale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-19-2015, 01:14 PM
  4. Copy paste - cute paste macro almost working
    By graiggoriz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-27-2014, 12:33 PM
  5. [SOLVED] Find, then copy and paste macro not working
    By ufopilot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2014, 06:46 AM
  6. [SOLVED] Macro to copy, then paste row in multiple sheets not working
    By dystopianprotagonist in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2013, 09:37 PM
  7. copy paste macro not working
    By nicko54 in forum Excel General
    Replies: 1
    Last Post: 01-05-2011, 05:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1