+ Reply to Thread
Results 1 to 14 of 14

Need help with copying and pasting using VBA/macro

  1. #1
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Need help with copying and pasting using VBA/macro

    Hello, a friend helped me to create a macro using VBA to copy and paste from several tabs into one tab. I want to add to the macro by saying that all values are to be copied and pasted from my selection (columns B to T) only if there are values in column B. So if column B has values from line 1 to 100, then to copy and paste all values from column B1 to T100 whether there are blank values in T100 or not.
    Can someone help me with this? I'm new to all this so if you can use layman terms, that would be much appreciated.

    Please Login or Register  to view this content.
    Last edited by Pepe Le Mokko; 04-03-2020 at 10:02 AM. Reason: Tags

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Need help with copying and pasting using VBA/macro

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I did it for you this time. Please read forum rules. Thanks

  3. #3
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Need help with copying and pasting using VBA/macro

    Hi, I have recoded a little bit, but this should do the trick:
    Please Login or Register  to view this content.
    Cheers
    Erwin
    I started learning VBA because I was lazy ...
    Still developing.... being more lazy...

  4. #4
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Re: Need help with copying and pasting using VBA/macro

    Hello Erwin,

    Thanks for helping. However, when I tried to run it, it kept running and caused my Excel file to crash. I'm assuming you tested it on your end and didn't do that to you? Maybe I'm missing something. Much appreciated.

  5. #5
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Need help with copying and pasting using VBA/macro

    please upload your workbook then via the attachment manager

    Cheers
    Erwin

  6. #6
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Re: Need help with copying and pasting using VBA/macro

    Hello, it worked. I forgot to include the "Option Explicit" part at the top. However, would you be able to help me again by only copying from rows 2 so that the headers are now copied and pasted as well?

  7. #7
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Re: Need help with copying and pasting using VBA/macro

    The header being row 1. Also, completely clueless but where is the attachment manager?

  8. #8
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Re: Need help with copying and pasting using VBA/macro

    Actually, I figured out how to not paste the header from every tab. Now I'm just wondering if there can be something added to the macro where it would copy and paste the header from the tab after sheet1 into sheet1 before it does the copying and pasting of the values.

  9. #9
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Need help with copying and pasting using VBA/macro

    Hi Sahaccount
    if you go to your quick reply, you see at the bottom: "Go Advanced"; cliclk that and you will see a lot of other options, including the attachment manager.

    Cheers
    Erwin

  10. #10
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Re: Need help with copying and pasting using VBA/macro

    Hello,

    Hopefully I attached it correctly.
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Need help with copying and pasting using VBA/macro

    Perfect, You said it yourself:
    The header being row 1.
    so you can change this:
    Please Login or Register  to view this content.
    Cheers
    Erwin

  12. #12
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Re: Need help with copying and pasting using VBA/macro

    Hello,

    I do want "i" to equal "2 To currentsheetlastrow" because I only want the values and not the headers copied and pasted over, unless I can somehow copy and paste the header and values from the first tab over and then only copy the values and not the header from the rest of the tab over as well.

    So if the VBA works correctly, when you run it, the header and the values from the first tab should copy and paste over but then the rest of the tabs would copy over also but without the headers. If this is not doable, then that's fine too. I'll see if I can find anything else on google that can help as I know it's getting more complex. Thanks so much in advance.

  13. #13
    Valued Forum Contributor Eastw00d's Avatar
    Join Date
    02-29-2020
    Location
    Breda, NL
    MS-Off Ver
    2016, 2019
    Posts
    833

    Re: Need help with copying and pasting using VBA/macro

    ah, so in that case you can add another line After Set wsTarget = Worksheets("Sheet1"). :
    Please Login or Register  to view this content.
    Of course you can pick any sheet in stead of "sheet2"

    Cheers
    Erwin
    Last edited by Eastw00d; 04-07-2020 at 11:50 AM.

  14. #14
    Registered User
    Join Date
    04-03-2020
    Location
    USA
    MS-Off Ver
    2013
    Posts
    8

    Re: Need help with copying and pasting using VBA/macro

    Thanks so much, Erwin! It worked! Again, I can't thank you enough. Stay safe and healthy.

+ 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] Macro for copying from one sheet and pasting into another
    By T.Turner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2020, 06:13 PM
  2. [SOLVED] Macro for copying and pasting
    By gz3s36 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2017, 09:58 PM
  3. Macro not copying / pasting
    By rz6657 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2012, 07:05 PM
  4. copying and pasting tabs macro
    By floricita in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-02-2010, 06:02 AM
  5. Is there a macro for copying and pasting data..
    By Tibby in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2008, 09:40 AM
  6. Copying and Pasting:write a macro
    By teresa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2005, 06:05 PM
  7. [SOLVED] Simple copying and pasting macro
    By Henrik in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2005, 08:06 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