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

Поділитися
Вставка
  • Опубліковано 6 жов 2024
  • Join 400,000+ professionals in our courses here 👉 link.xelplus.c...
    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....
    🔑 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.co...
    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.co...
    ➡️ Join this channel to get access to perks: / @leilagharani
    👕☕ Get the Official XelPlus MERCH: xelplus.creato...
    🎓 Not sure which of my Excel courses fits best for you? Take the quiz: www.xelplus.co...
    🎥 RESOURCES I recommend: www.xelplus.co...
    🚩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

КОМЕНТАРІ • 189

  • @LeilaGharani
    @LeilaGharani  8 місяців тому

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

  • @abrahamjeethu
    @abrahamjeethu 2 роки тому +10

    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.

  • @GosCee
    @GosCee Рік тому

    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.

  • @kuuuyajim
    @kuuuyajim 2 роки тому +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  2 роки тому

      Glad I could help!

    • @hamphrey.olendo65
      @hamphrey.olendo65 2 роки тому

      @@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 2 роки тому

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

  • @CarneSagrado
    @CarneSagrado Рік тому

    .
    (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.
    .

  • @hamphrey.olendo65
    @hamphrey.olendo65 2 роки тому +1

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

  • @medasbabu
    @medasbabu 3 роки тому

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

  • @MohammadAshooryan
    @MohammadAshooryan 6 років тому

    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  6 років тому +1

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

  • @DuyenLe-kt3xx
    @DuyenLe-kt3xx 4 місяці тому

    a very instructive tutorial, thanks

  • @abdallah.kandiel
    @abdallah.kandiel 6 років тому +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  6 років тому +1

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

  • @ajexcel
    @ajexcel 6 років тому

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

    • @LeilaGharani
      @LeilaGharani  6 років тому

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

  • @ProgramadorExcelVBA
    @ProgramadorExcelVBA 4 роки тому +1

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

  • @PraveenKumar-hv9is
    @PraveenKumar-hv9is 6 років тому

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

    • @LeilaGharani
      @LeilaGharani  6 років тому

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

  • @SanthoshKumar-xy3zm
    @SanthoshKumar-xy3zm 2 роки тому

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

  • @sahilkadu5409
    @sahilkadu5409 5 років тому

    Leila u teach so well😭 im ur big fan

  • @helenasvensson6595
    @helenasvensson6595 11 місяців тому

    Magic! So well explained!

  • @excelisfun
    @excelisfun 6 років тому +1

    Thanks for the Copy Paste VBA Fun!!

  • @chaitanyatuckley4666
    @chaitanyatuckley4666 3 роки тому

    Thanks a lot Madam, Keep up the good work.

  • @claudegiguere8731
    @claudegiguere8731 3 роки тому

    Wow! Another great tutorial, thanks Leila!

  • @sandeepkothari5000
    @sandeepkothari5000 6 років тому

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

    • @LeilaGharani
      @LeilaGharani  6 років тому

      I hope you find a lot of value in the course for your work! Thank you for your support.

    • @sandeepkothari5000
      @sandeepkothari5000 6 років тому +1

      Welcome.

  • @virenk3813
    @virenk3813 5 років тому

    You made it so simple. That's great

  • @Melki
    @Melki Рік тому

    Thanks for helping me with work 👍

  • @anthonyflorianterrapon6575
    @anthonyflorianterrapon6575 3 роки тому +1

    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 Місяць тому

    Thank you

  • @afriyatno5557
    @afriyatno5557 4 роки тому

    thank you, its very helpfull for me

  • @kctechie
    @kctechie 11 місяців тому

    THANK YOU!!!

  • @Melki
    @Melki 4 місяці тому

    Thanks

  • @RondenBreems
    @RondenBreems 3 роки тому

    Crystal clear!

  • @quasipseudo1
    @quasipseudo1 6 років тому

    Explained very good. Thanks!

    • @LeilaGharani
      @LeilaGharani  6 років тому

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

  • @mohitdhanwani5540
    @mohitdhanwani5540 6 років тому

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

  • @ismailismaili0071
    @ismailismaili0071 6 років тому

    thank you so much Ms. Leila you are great appreciated

  • @sarasamin
    @sarasamin 4 роки тому

    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

  • @yantowk8008
    @yantowk8008 5 років тому

    Very helpful and useful.
    Thank you.

  • @MohAboAbdo
    @MohAboAbdo 4 роки тому

    Thank you very much.

  • @Melki
    @Melki 3 дні тому

    Terima kasih.

  • @sivaramakrishnayarlagadda7007
    @sivaramakrishnayarlagadda7007 6 років тому

    Thanks for received in your valuable tricks .

  • @udaymohannamburi5039
    @udaymohannamburi5039 3 роки тому

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

  • @johnborg6005
    @johnborg6005 6 років тому +1

    Thanks leila. This was very interesting :)

  • @georgekiwi8178
    @georgekiwi8178 6 років тому

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

  • @kishangzp
    @kishangzp 4 роки тому

    Great Video... thumps up!

  • @samuelgirma8532
    @samuelgirma8532 3 роки тому

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

  • @mohamedabouelfetouh6265
    @mohamedabouelfetouh6265 5 років тому

    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

  • @ceorgcl
    @ceorgcl 5 років тому

    Helpful
    Thanks for the vedio Leila

  • @magorzatagaik2440
    @magorzatagaik2440 6 років тому

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

    • @LeilaGharani
      @LeilaGharani  6 років тому

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

  • @Melki
    @Melki Рік тому

    Thank you :)

  • @ANGELiki1992
    @ANGELiki1992 3 роки тому

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

  • @Melki
    @Melki 9 місяців тому

    Thanks!

  • @richardnina79
    @richardnina79 Рік тому

    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

  • @sandeepkothari5000
    @sandeepkothari5000 6 років тому

    LEILA, U R GR8!

  • @ShikhaSharma-qw4px
    @ShikhaSharma-qw4px 5 років тому +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

  • @Melki
    @Melki 8 місяців тому

    Thanks

    • @LeilaGharani
      @LeilaGharani  8 місяців тому

      Thank you! I'm glad the video was helpful for you.

  • @theenlightened1s
    @theenlightened1s 5 років тому

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

  • @khalidalisubhanallah2947
    @khalidalisubhanallah2947 6 років тому

    Thanks mam Nice Video

  • @stevennye5075
    @stevennye5075 5 років тому

    well done

  • @bassisessaidexcel
    @bassisessaidexcel 2 роки тому

    Merci

  • @Melki
    @Melki Рік тому

    Terima kasih.

  • @danielmathivathan7391
    @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?

  • @pprahul2003
    @pprahul2003 Рік тому

    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?

  • @debjitsarkar2651
    @debjitsarkar2651 4 роки тому

    awesome

  • @anandchaudhari8528
    @anandchaudhari8528 6 років тому

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

  • @hosseinhosseinpoor4845
    @hosseinhosseinpoor4845 3 роки тому

    thanks thanks thanks

  • @HowtoHacks
    @HowtoHacks 3 роки тому

    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.

  • @abdullahquhtani8058
    @abdullahquhtani8058 6 років тому

    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  6 років тому

      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 6 років тому

      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  6 років тому +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.

  • @issamalkhesho6775
    @issamalkhesho6775 3 роки тому

    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

  • @yogendrayogesh3307
    @yogendrayogesh3307 3 роки тому

    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.

  • @CP-yl5bl
    @CP-yl5bl 4 роки тому

    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.

  • @sumitjain3017
    @sumitjain3017 4 роки тому

    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

  • @SPARK9026ONLINE
    @SPARK9026ONLINE 4 роки тому

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

  • @sandeepkothari5000
    @sandeepkothari5000 6 років тому

    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  6 років тому +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.

  • @abdallah.kandiel
    @abdallah.kandiel 6 років тому

    Here i am
    Welcome back ur highness

  • @kaylasoriente
    @kaylasoriente Рік тому

    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!

  • @mkdon3988
    @mkdon3988 2 роки тому

    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.

  • @Disaenz10
    @Disaenz10 6 років тому

    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  6 років тому

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

    • @Disaenz10
      @Disaenz10 6 років тому

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

  • @pravin.kakade
    @pravin.kakade 2 роки тому

    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.

  • @josephking3937
    @josephking3937 2 роки тому

    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.

  • @seemoon6338
    @seemoon6338 4 роки тому

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

  • @AmitSharma-po1zb
    @AmitSharma-po1zb 5 років тому

    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

  • @elasmarsaadallah6126
    @elasmarsaadallah6126 3 роки тому

    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

  • @GalinaT100
    @GalinaT100 2 роки тому

    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.

  • @edgarestuardorodriguezflor9017
    @edgarestuardorodriguezflor9017 3 роки тому

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

  • @jerry5149
    @jerry5149 5 місяців тому

    For the first time, I was confused by your lesson?

  • @mdzen22e
    @mdzen22e 5 років тому

    can you show how to loop the selection

  • @mahendhiranp4856
    @mahendhiranp4856 2 роки тому

    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?

  • @pawankoli2009
    @pawankoli2009 2 роки тому

    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.

  • @barbarasakowicz5338
    @barbarasakowicz5338 4 роки тому

    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

  • @farzanmoha8935
    @farzanmoha8935 5 років тому

    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!

  • @mananaeem
    @mananaeem 5 років тому

    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

  • @accnotech3863
    @accnotech3863 6 років тому

    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  6 років тому

      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: ua-cam.com/video/acGJb9Oojho/v-deo.html

  • @InsideMyWall
    @InsideMyWall 2 роки тому

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

  • @parimalaarya2041
    @parimalaarya2041 6 років тому

    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

  • @benaragon12
    @benaragon12 4 роки тому

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

  • @mohammadalmomani1193
    @mohammadalmomani1193 5 років тому

    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

  • @นภสว
    @นภสว 3 роки тому

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

  • @unpred_ton
    @unpred_ton 5 років тому

    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  5 років тому +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 UA-cam.

  • @Dopeboyz789
    @Dopeboyz789 5 років тому

    What about a copy and paste button

  • @siddh8508
    @siddh8508 2 роки тому

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

  • @Missyvjd
    @Missyvjd 5 місяців тому

    excellent presenter but cannot deal with the music

  • @brigadeshivu
    @brigadeshivu 4 роки тому

    How to auto repeat paste special at each interval of time

  • @sivaramakrishnayarlagadda7007
    @sivaramakrishnayarlagadda7007 6 років тому

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

    • @LeilaGharani
      @LeilaGharani  6 років тому

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

  • @55MLF
    @55MLF 4 роки тому

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