Easiest Ways to Copy and Paste Cells with Excel VBA (copy, pastespecial, resize & offset)

Sdílet
Vložit
  • čas přidán 18. 04. 2018
  • Join 400,000+ professionals in our courses here 👉 link.xelplus.com/yt-d-all-cou...
    Discover the power of Excel's VBA with our tutorial on Copy and Paste Special methods. Perfect for those looking to automate and enhance their Excel tasks, this video covers essential techniques, including resizing ranges and excluding headers.
    ⬇️ Download the workbook here: pages.xelplus.com/vba-copy-re...
    🔑 What You'll Learn:
    ▪️ Essential VBA Methods: Explore two vital methods in Excel VBA - Copy and Paste Special.
    ▪️ Variable Size Range Copying: Learn how to copy ranges of varying sizes, a handy skill for dynamic data sets.
    ▪️ Using Resize Property: Understand how to resize a range before copying, ideal for situations like excluding headers in a current region.
    🎓 Get access to the full Excel VBA Course here 👉 www.xelplus.com/course/excel-...
    This tutorial shows you how you can copy and paste with VBA. We use the copy method as well as the pastespecial method.
    The copy method in VBA, copies data, as well as formatting, formulas, comments etc - with the pastespecial method, you have more control over your paste options. For example, you can paste formatting only - or choose to paste values as well as number formatting.
    I also show you how to use the resize property, so you can change the size of the current region before you copy. This is good for cases where you want to copy the data but exclude the header. Here we add in OFFSET as well.
    ★★ Links to related videos: ★★
    Referencing Ranges with VBA: • Excel VBA: Referring t...
    Learn about Visual Basic Editor: • Excel VBA tutorial for...
    Recording macros: • Excel VBA: Copy Data f...
    Properties & methods in VBA: • Learn How to Use Prope...
    ★ My Online Excel Courses ★ ► www.xelplus.com/courses/
    ➡️ Join this channel to get access to perks: / @leilagharani
    👕☕ Get the Official XelPlus MERCH: xelplus.creator-spring.com/
    🎓 Not sure which of my Excel courses fits best for you? Take the quiz: www.xelplus.com/course-quiz/
    🎥 RESOURCES I recommend: www.xelplus.com/resources/
    🚩Let’s connect on social:
    Instagram: / lgharani
    LinkedIn: / xelplus
    Note: This description contains affiliate links, which means at no additional cost to you, we will receive a small commission if you make a purchase using the links. This helps support the channel and allows us to continue to make videos like this. Thank you for your support!
    #excel #vba

Komentáře • 183

  • @LeilaGharani
    @LeilaGharani  Před 5 měsíci

    Grab the file I used in the video from here 👉 pages.xelplus.com/vba-copy-resize-file

  • @abrahamjeethu
    @abrahamjeethu Před 2 lety +9

    Let me be very frank with you Leila. I am an ardent viewer of many videos on VBA. if ever there is somebody who does the explanations in such a marvelous way, It's YOU...No other people. Man, you are just awesome. Hats off, God bless you.

  • @excelisfun
    @excelisfun Před 6 lety +1

    Thanks for the Copy Paste VBA Fun!!

  • @GosCee
    @GosCee Před 10 měsíci

    Leila, has anyone told you lately how awesome you are? You are the best! It's the first time I've understood the resize range expression. Your explanation is so clear. Thank you very much.

  • @hamphrey.olendo65
    @hamphrey.olendo65 Před rokem +1

    love your tutorials so much, indeed you are an an expert

  • @claudegiguere8731
    @claudegiguere8731 Před 3 lety

    Wow! Another great tutorial, thanks Leila!

  • @ProgramadorExcelVBA
    @ProgramadorExcelVBA Před 4 lety +1

    Leila vba é outro nível, show de conteúdo.

  • @CarneSagrado
    @CarneSagrado Před rokem

    .
    (Love your hands & nails, and this color is the best for them 💖💖💖💖)
    .
    Im glad I discovered your channel. Am a programmer (COBOL, Java, C++, you name it), but only now am I needed for Excel/VBA projects, so I'm watching all of your videos.
    .

  • @kuuuyajim
    @kuuuyajim Před rokem +2

    I find myself digging into your videos more often than before. And thank you for this tutorial, I was able to shorten the macro I recorded. 😀

    • @LeilaGharani
      @LeilaGharani  Před rokem

      Glad I could help!

    • @hamphrey.olendo65
      @hamphrey.olendo65 Před rokem

      @@LeilaGharani kindly is there excel formula to copy special values from one cell to another?, in such that when the initial cell is updated, the copied cell doesn't change

    • @hamphrey.olendo65
      @hamphrey.olendo65 Před rokem

      @@LeilaGharani hi leila, kindly is there excel formula to copy special values, without using vba?

  • @medasbabu
    @medasbabu Před 3 lety

    Hi Leila , you make it so simple, thanks for the short video, very keen to learn more VBA, thanks

  • @georgekiwi8178
    @georgekiwi8178 Před 5 lety

    Great Video Leila- really enjoying these videos! Great info :)

  • @ajexcel
    @ajexcel Před 6 lety

    Its looking so simple in this video than actually it would be..thanks a lot leila..will waiting for more on this..

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      Thanks Ajay. It does get easier the more we practice :)

  • @MohammadAshooryan
    @MohammadAshooryan Před 6 lety

    hi leila(excelwoman),as usual, your simple method learning is very usefull. thanks for sharing your excel knowlege.looking forward your next lectue.

    • @LeilaGharani
      @LeilaGharani  Před 6 lety +1

      Thank you Mohammad. I'm happy you like the teaching style. Next VBA video will be up next week :)

  • @yantowk8008
    @yantowk8008 Před 5 lety

    Very helpful and useful.
    Thank you.

  • @helenasvensson6595
    @helenasvensson6595 Před 8 měsíci

    Magic! So well explained!

  • @SanthoshKumar-xy3zm
    @SanthoshKumar-xy3zm Před 2 lety

    Very well explained.Thank you so much mam🙏🙏🙏🙏🙏

  • @DuyenLe-kt3xx
    @DuyenLe-kt3xx Před měsícem

    a very instructive tutorial, thanks

  • @virenk3813
    @virenk3813 Před 4 lety

    You made it so simple. That's great

  • @quasipseudo1
    @quasipseudo1 Před 6 lety

    Explained very good. Thanks!

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      You're very welcome. Glad you like the explanation.

  • @sahilkadu5409
    @sahilkadu5409 Před 5 lety

    Leila u teach so well😭 im ur big fan

  • @mohitdhanwani5540
    @mohitdhanwani5540 Před 6 lety

    Thanks for the video ma'am....nicely explained...loved it! 😊

  • @ceorgcl
    @ceorgcl Před 5 lety

    Helpful
    Thanks for the vedio Leila

  • @ismailismaili0071
    @ismailismaili0071 Před 6 lety

    thank you so much Ms. Leila you are great appreciated

  • @sandeepkothari5000
    @sandeepkothari5000 Před 6 lety

    LEILA, U R GR8!

  • @johnborg6005
    @johnborg6005 Před 6 lety +1

    Thanks leila. This was very interesting :)

  • @chaitanyatuckley4666
    @chaitanyatuckley4666 Před 3 lety

    Thanks a lot Madam, Keep up the good work.

  • @sivaramakrishnayarlagadda7007

    Thanks for received in your valuable tricks .

  • @afriyatno5557
    @afriyatno5557 Před 3 lety

    thank you, its very helpfull for me

  • @user-nm4ul6gr6o
    @user-nm4ul6gr6o Před 4 lety

    Thank you very much.

  • @kishangzp
    @kishangzp Před 4 lety

    Great Video... thumps up!

  • @Melki
    @Melki Před rokem

    Thanks for helping me with work 👍

  • @sarasamin
    @sarasamin Před 4 lety

    I always learn a lot from your videos..Thank you so much.I have a
    question about currentregion,is there a way to copy paste just a few rows or columns that acts like currentregion "to be dynamic"
    you're the best

  • @RondenBreems
    @RondenBreems Před 2 lety

    Crystal clear!

  • @abdallah.kandiel
    @abdallah.kandiel Před 6 lety +1

    One more thing
    U concentrate on the points thar matters
    And usefull to daily tasks
    Thanks for making excel peace of cake
    Thanks leila

    • @LeilaGharani
      @LeilaGharani  Před 6 lety +1

      Thank you! Really appreciate your support of all the videos.

  • @kctechie
    @kctechie Před 8 měsíci

    THANK YOU!!!

  • @mohamedabouelfetouh6265

    Hello Leila thanks a lot for the video, i wonder if you can do copy from multiple worksheets and pastespecial values to a single worksheet

  • @anthonyflorianterrapon6575

    Hi Leila ! Your video is great. I need your help on how to copy paste data into a table format. I need to add it at the end of the table and with your method it always return an error...

  • @Melki
    @Melki Před rokem

    Thank you :)

  • @CP-yl5bl
    @CP-yl5bl Před 4 lety

    Leila...great tutorial.I have a question.On sheet1 I have a table W8:AA450.I want to bring data from this table to sheet2 in a fixed range A4:A8,one row at a time.Because for each row of data from sheet1 table ,I'm doing some calculation on sheet2.Can you make a video or reply here thx.

  • @Melki
    @Melki Před 4 měsíci

    Thanks

  • @ANGELiki1992
    @ANGELiki1992 Před 2 lety

    Thanks!!!!!!!!!!!!!!!

  • @danielmathivathan7391

    Hi Leila is there a non-vba solution were you can convert formulas to values in cells which are associated with dates past a certain date?

  • @sumitjain3017
    @sumitjain3017 Před 4 lety

    What if we want to copy paste with cell dimensions (Row Height, Col Width, Merge, Picture etc) as we do mannually using fomat painter on clip board

  • @udaymohannamburi5039
    @udaymohannamburi5039 Před 3 lety

    Hie Leila
    The video was awesome
    In the same way can we copy (fixed range) to paste special (in dynamic) only after giving command.

  • @Melki
    @Melki Před rokem

    Thanks!

  • @Melki
    @Melki Před 10 dny

    Terima kasih.

  • @richardnina79
    @richardnina79 Před rokem

    Thank you very much!
    Could you please give the code for copy-paste a table that to a specific cell on another sheet (i.e.: Print?
    NB: That latter sheet has information such as Name and signature, and date of order. This sheet has to be printed

  • @55MLF
    @55MLF Před 4 lety

    When I copy with paste special, it deletes my conditional formatting (color coding). Am I doing something wrong?

  • @sandeepkothari5000
    @sandeepkothari5000 Před 6 lety

    Leila, I enrolled myself for your VBA course today. Meet you there.

  • @HowtoHacks
    @HowtoHacks Před 3 lety

    What if you have formulas in the range and are using iferror to make them blank? I'm trying to only copy the cells with text from the formulas and this method works but it's copying all the cells with formulas in them.

  • @magorzatagaik2440
    @magorzatagaik2440 Před 6 lety

    Very interesting lesson. I would like to ask you if you can prepare tutorial - how to use excel formulas in VBA?

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      Glad you like it. Ok - will add this to my list. Thank you for your suggestion.

  • @anandchaudhari8528
    @anandchaudhari8528 Před 6 lety

    best of the best..........

  • @bassisessaidexcel
    @bassisessaidexcel Před 2 lety

    Merci

  • @stevennye5075
    @stevennye5075 Před 4 lety

    well done

  • @debjitsarkar2651
    @debjitsarkar2651 Před 4 lety

    awesome

  • @PraveenKumar-hv9is
    @PraveenKumar-hv9is Před 6 lety

    Your way of teaching is amazing madam thanks for given such good VBA videos class and teaching.

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      You're very welcome Praveen. I'm happy you like the videos and the teaching :)

  • @khalidalisubhanallah2947

    Thanks mam Nice Video

  • @hosseinhosseinpoor4845

    thanks thanks thanks

  • @samuelgirma8532
    @samuelgirma8532 Před 3 lety

    If you have please recommend the video, about Excel Vba paste special value if looking or finding Todays value . 💚💛❤️

  • @kaylasoriente
    @kaylasoriente Před rokem

    Hi Ms. Leila. I would just like to ask if it's possible to copy paste data on a spreadsheet even if the file is in a view mode only? My teammates and I are having a hard time working using this file because we have to manually look at the items, copy and paste it on a separate sheet so we cannnot vlookup the items. We manually click ctrl + f then ctl + c & p instead. Your helo would be very valuable to us. Thank you!

  • @Disaenz10
    @Disaenz10 Před 6 lety

    Hi Leila thank you for your videos. Do you have or have any plans on how to migrate data from one excel workbook that is in one carpet to another workbook in another carpet ? Let's say that I have monthly reports and I want to consolidate them all in just one sheet.
    Thanks !

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      Yes - I cover these in my VBA course. I will try and add one of the videos to CZcams as well in the next weeks...

    • @Disaenz10
      @Disaenz10 Před 6 lety

      Leila Gharani awesomeee, please let me know when you upload it.
      Thanks!

  • @parimalaarya2041
    @parimalaarya2041 Před 5 lety

    Hi I have a list of names in a column I need to apply filter for each names and copy the related data of names ,how to do that in VBA code pls share the code

  • @yogendrayogesh3307
    @yogendrayogesh3307 Před 3 lety

    Any way to actually find all cells in a sheet with same value and repliacte the cell formatting across all whenever its changed on any of those cells.

  • @pprahul2003
    @pprahul2003 Před 11 měsíci

    What if the data has broken rows i.e if the data is spread in different rows and few rows are blank in between. Will current range work?

  • @theenlightened1s
    @theenlightened1s Před 5 lety

    Please share how we can copy only the rows that fulfil a certain criteria.. thanks

  • @GalinaT100
    @GalinaT100 Před 2 lety

    How to auto squeeze weekends column up to 0.8 width for all year? The date is 11/05/2021 on the top the column. I need squeeze like ## size for them.

  • @AmitSharma-po1zb
    @AmitSharma-po1zb Před 5 lety

    Hi Leila, need a small help, actually i need to copy data from one worksheet to another only when the headers of both worksheets match. i have written a code which is actually copying the entire range from one worksheet to another but actually the situation is, once the headers match, the data gets copied and then next time the data should get copied skipping one row in destination worksheet. please help

  • @mdzen22e
    @mdzen22e Před 5 lety

    can you show how to loop the selection

  • @issamalkhesho6775
    @issamalkhesho6775 Před 3 lety

    Hello Leila, I am wondering if you can help me with the following task: I have two work books, the first one is to create invoice with customer information and purchasing details , the second workbook is to save dynamically the data including the invoice number , date, total price ..etc. extracted form the first workbook . At the end of the day I am going to save both workbooks and shut down the computer . what I would like to have the next day is when I open the first workbook , I want to open the second workbook using a command button on the first workbook , also I want to be able to get the last invoice number saved in the second workbook to be transferred to the first workbook with adding one to it . the invoice numbers are saved in column A2 :A in the second workbook. the invoice cell number is L11 in the first workbook .
    I have created a command button on the first workbook to open the second workbook , that is successful , but I am not able to write the correct VBA code to transfer the last row cell value of column A from second workbook to the first workbook .
    Can you please help me ?
    thanks
    Issam

  • @accnotech3863
    @accnotech3863 Před 6 lety

    its a great tutorial, but what if, i want to copy and paste my data to a template that doesn't allow copy paste, well in such a case we have to link name ranges, or cell references, isnt it? or is there any good way then this

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      If the sheet is protected, you can un-protect in the macro before pasting and then re-protect. If you are using named ranges, you can reference that directly in the macro. This video shows different ways of writing to ranges: czcams.com/video/acGJb9Oojho/video.html

  • @josephking3937
    @josephking3937 Před rokem

    So how do you copy a range from one workbook to another using Control C to copy the range, then go to the sheet you want to paste into and click a paste button that does a PasteSpecial on the values? it seems I can make this work with an unlocked file, but when I lock it down, it will not let me paste through the macro button.

  • @mahendhiranp4856
    @mahendhiranp4856 Před 2 lety

    Hi,
    If I run VBA of Paste special method. The pasted column Turns into a text.
    Could you Please help me to covert the pasted column into number format in VBA itself?

  • @edgarestuardorodriguezflor9017

    Hi, how do I resize a chart width using offset and counta with vba? Pleas help me

  • @seemoon6338
    @seemoon6338 Před 4 lety

    hi can you tell me how can we to print userform fit to paper ..pleas

  • @ShikhaSharma-qw4px
    @ShikhaSharma-qw4px Před 5 lety +1

    I want to copy data from multiple sheets in a workbook and paste it to one sheet in other workbook. It would be great if anyone can help

  • @pawankoli2009
    @pawankoli2009 Před 2 lety

    Hi Leila,
    Need you help, it is possible to export entire excel file with same data and formats but not formulas. i have a file has charts, pivots, report dashboard with sources data but i dont want to share this file with formulas.

  • @farzanmoha8935
    @farzanmoha8935 Před 5 lety

    Hi Leila, can you please tell me how can I paste in only UN HIDE cells in excel (the visible ones)? Alt; only works for copy the visible cells not for paste in visible ones. Thank you!

  • @mkdon3988
    @mkdon3988 Před 2 lety

    Hi leila,
    Is there a way to copy and paste missing information from 1 column to another by match.??
    Example: colm1 column 2
    123 a 342
    342 c 123
    Automatically copy missing carctrs a & c wher they belong.

  • @elasmarsaadallah6126
    @elasmarsaadallah6126 Před 3 lety

    how can i use a formula to a table without loop in vba , for example i want to replace a array 1 ,5 , 6, 8 by the same array + 4 : 5, 9, 10, 12

  • @SPARK9026ONLINE
    @SPARK9026ONLINE Před 3 lety

    I need your help about VBA, will you do please, when you free time ?

  • @sandipmakwana6462
    @sandipmakwana6462 Před 4 lety

    👌

  • @barbarasakowicz5338
    @barbarasakowicz5338 Před 4 lety

    Hey, In your Video you didn't manage how can I Past all Tablle + Color about the table but as a Value. SO I want to keep the color and point as a Value

  • @mohammadalmomani1193
    @mohammadalmomani1193 Před 5 lety

    Hello
    I am trying to find an vba code to copy and paste every range of rows like(A1:C19).copy and paste in word file as image then copy from (A20:C39) and paste in the same word file and so on for the rest of the table in excel. they have told me that I need to use the looping in excel but I don't know exactly how to do it …. please help if you can

  • @mananaeem
    @mananaeem Před 4 lety

    I need code to collect data from different workbooks books in folder and copy each relevant sheet in master file.
    I have three different file in folder and have 3 works sheets in each file. I need to loop through each file and copy relevant sheet to relevant master file. Than data from next file to master workbook. Waiting for reply, please Naeem

  • @pravin.kakade
    @pravin.kakade Před rokem

    Hi Ma'am, I have a question. How can we copy paste a data which has data+images.??
    If we are working in one Excel and there is data+ images ( just like BOQ or quotation) so how can we copy or paste the some data ? Because sometimes what happens that the images do not copy well in format. So need solution please.

  • @lilitvardanyan4366
    @lilitvardanyan4366 Před 6 lety

    👍👍👍

  • @brigadeshivu
    @brigadeshivu Před 4 lety

    How to auto repeat paste special at each interval of time

  • @benaragon12
    @benaragon12 Před 4 lety

    How do I copy a cell into another cell if its blank using VBA macro?

  • @johnsonbolhayon4790
    @johnsonbolhayon4790 Před 5 lety

    How can this be applied from a different sheet?
    What needs to be modified? I'd like to cut the datasource and paste it to a different sheet.

    • @LeilaGharani
      @LeilaGharani  Před 5 lety +1

      The worksheet name needs to be added before the range reference. This is something we cover in detail inside the course - I'll add it to my list to put out some videos on this topic for CZcams.

  • @abdullahquhtani8058
    @abdullahquhtani8058 Před 6 lety

    One very important questions raises here!!
    Is it possible to copy different ranges from different sheets and paste them in a specific range?!

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      Hi Abdullah - yes - you just have to put the sheet name before the range - you can do this for example by Worksheets("Source").range("A4").currentregion.copy and paste it in another sheet, by mentioning the sheet name before the range. You can also use the code name of the sheet instead of referring to it through the sheets collection.

    • @abdullahquhtani8058
      @abdullahquhtani8058 Před 6 lety

      Leila Gharani I tried that before but I had to copy and paste two or three times. My question was:
      Is it possible to copy two different ranges from two sheets and paste those two ranges in a specific range in code. I hope I made it clear. Thank you so much for your cooperation.

    • @LeilaGharani
      @LeilaGharani  Před 6 lety +1

      I see - If all your areas are one sheet, you could do it in one line like this: Range("A4:B7,A28:B32,A40:B42").Copy and then paste in one cell. But if your areas are in different sheets, you could use variables for the different areas and then do a loop to copy paste them in the loop. You'll need a variable for the next available row as well.

  • @InsideMyWall
    @InsideMyWall Před 2 lety

    How to browse a folder or files via Excel VBA, copy the name and paste it in a specified 'word' file??

  • @sivaramakrishnayarlagadda7007

    how to copy apply after auto filter only particular rows.
    ex. apply autofilter only first 4 rows copy.
    Please give me answer.

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      To copy only visible rows in the autofilter, you can use this code: ActiveSheet.AutoFilter.Range.Copy

  • @pouoiza7163
    @pouoiza7163 Před 3 lety

    dear sir
    I woukd like to learning about excel vba sumif function .
    please sir.

  • @siddh8508
    @siddh8508 Před 2 lety

    how to copy bulk records with copy and paste specials with macros, its only copying 900 records maximums

  • @Dopeboyz789
    @Dopeboyz789 Před 5 lety

    What about a copy and paste button

  • @dasrotrad
    @dasrotrad Před 6 lety

    When I run ?Range("A4").CurrentRegion.Offset(1,0) in the immediate window, I get Run-time error 13: type mismatch.
    The line of code, "Range("A4").CurrentRegion.Offset(1,0)" is showing RED in the VBE.
    I also tried running "Application.Workbooks ("Book1").Worksheets("Sheet2").Select" in Workbook "Book1" and I got a runtime error: Run-time error 9: Subscript out of range. Could this be a related issue?
    Any idea what is going on?
    Thank you.
    Robert

  • @moneebshaikh
    @moneebshaikh Před 3 lety

    How to copy paste data with specific header name

  • @sandeepkothari5000
    @sandeepkothari5000 Před 6 lety

    1. In VBA code, what are arguments to Copy-Paste following:
    a. “Äll merging conditional formats” option showing in paste special dialogue box;
    b. paste link;
    c. Row heights;
    d. fixed picture &
    e. linked picture;
    f. use of camera to copy & paste pictures, images.

    • @LeilaGharani
      @LeilaGharani  Před 6 lety +1

      Hi Sandeep - here it's best to use the macro recorder and test each one. This gives you a quick glossary of all the options available - you can copy and paste the code and adjust for your projects.

  • @sandeepkothari5000
    @sandeepkothari5000 Před 6 lety

    how can I download the workbook for my practice?

    • @LeilaGharani
      @LeilaGharani  Před 6 lety +1

      I see - the link is missing - I'll update it in a bit...will let you know.

    • @sandeepkothari5000
      @sandeepkothari5000 Před 6 lety

      Thanks.

    • @LeilaGharani
      @LeilaGharani  Před 6 lety

      The workbook is now available here: www.xelplus.com/vba-copy-paste/ - just scroll down to the bottom of the post.

    • @sandeepkothari5000
      @sandeepkothari5000 Před 6 lety

      Thanks a ton Leila.

  • @abdallah.kandiel
    @abdallah.kandiel Před 6 lety

    Here i am
    Welcome back ur highness