How to Use Arrays Instead of Ranges in Excel VBA

Поделиться
HTML-код
  • Опубликовано: 8 июл 2024
  • Learn how to write real-world Excel VBA code: 👉courses.excelmacromastery.com/
    FREE CHEAT SHEET: Get the free cheat sheet on VBA arrays here: (bit.ly/2MXsnz9)
    Subscribe to the channel here: bit.ly/36hpTCY
    How to Use Arrays Instead of Ranges in Excel VBA
    Most people don't realise that Arrays are exponentially faster than Ranges in Excel VBA.
    In this video I cover in detail how to replace ranges with arrays and make your code run faster.
    Useful VBA Shortcut Keys:
    View the Immediate Window: Ctrl + G
    View the Watch Window: Alt + V + H
    Tab: To move lines of code to the right(Indent).
    Shift + Tab: To move lines of code to the left(Outdent).
    Shift + F2: Get the definition of the item under the cursor.
    Ctrl + Shift + F2: Go to the last cursor position.
    Ctrl + Space: AutoComplete Word.
    Alt + F11: Switch between Excel and the VBA Editor.
    Ctrl + G: view the Immediate Window
    Ctrl + R: View the Project Explorer Window.
    Ctrl + Shift + 8(or Ctrl + *): Get the current region on a worksheet.
    F4: View the Properties Window.
    F5: Run the code from the current sub.
    F8: Step into the code.
    F9(or click left margin): Add a breakpoint to pause the code.

Комментарии • 261

  • @Excelmacromastery
    @Excelmacromastery  11 дней назад

    Learn how to write real-world Excel VBA code: 👉courses.excelmacromastery.com/

  • @TimePasser
    @TimePasser 3 года назад +2

    This is exactly what I am looking for. I work in telecom industry. It took me hours to process raw data.. now .. down to less than 20 mins with a humble system. Thank you .. where have you been 10 years ago ? I can't thank you enough .

  • @mike_case
    @mike_case 4 года назад +9

    Thank you Paul for all your content!!!
    Dictionaries, arrays, collections and classes are the best.

  • @BenjaminHouot
    @BenjaminHouot 4 года назад +57

    Best vba channel i ever found !

  • @grzesiekhallomoto5920
    @grzesiekhallomoto5920 4 года назад

    Magnificent.... I have very complex range operations which take my program 281 seconds to perform. With this method I reduced the time to under 5%.... Best ever YT content I've encountered. Keep doing, don't stop. Ever! It has the potential to be great...

  • @stevennye5075
    @stevennye5075 4 года назад +3

    I am self-taught and I didn't fully grasp this content the first couple of times I looked at it. I decided I needed to better understand it and it now makes sense.

  • @krn14242
    @krn14242 4 года назад +2

    Great job Paul. Love using arrays now. So much more efficient.

  • @fmichaelhemmer3762
    @fmichaelhemmer3762 2 года назад +3

    Absolutely fabulous instruction. Seeing the array filled with one line of code and then watching it crunch 2500 records in a blink, was the most fun I've had in a while... sad, but still fun! Thank you Paul.

  • @coryc9040
    @coryc9040 4 года назад

    From someone putzing around with VBA for a few years, finding R Studio was a godsend. Perhaps there are special instances where you might have to use Excel, but I'd advise anyone who thinks they should spend time learning to code VBA to give R a try.

  • @luismoreyra6804
    @luismoreyra6804 2 года назад +1

    Amazing!! I watched tons of vba videos (I'm newbie) and by far this video gives a incredible edge because of its clear and concise information. Excellent!! Great work, please keep it up!!

  • @terryy6938
    @terryy6938 3 года назад +1

    Absolutely a clear and concise explanation of using arrays. Well done! You gained another subscriber.

  • @johnhackwood1568
    @johnhackwood1568 4 года назад

    Another really 1st class video, really simple and robust code that covers so many practical situations

  • @querrythis
    @querrythis 2 года назад

    Incredible how efficient you codes are, yet explain it so simple. Genius!

  • @cherifnadjib3373
    @cherifnadjib3373 4 года назад

    From Algeria, thank you Paul for this vidéo.

  • @davidevecchio2474
    @davidevecchio2474 3 года назад +1

    Thanks a lot! A very clear explanation that addressed exactly what I was looking for. You're a great teacher!

  • @m-squaredcontractors9720
    @m-squaredcontractors9720 4 года назад +1

    Wow...i now really appreciate arrays. Very efficient compared to ranges. Thanks Paul

  • @natejewkes
    @natejewkes 4 года назад +3

    Where have you been all my life? This is awesome!

  • @jxggxr_dxv
    @jxggxr_dxv 4 года назад +2

    I like the format of your videos and the way you explain things. Even if I know some of them, I still watch just because you're one of the very few on youtube that is actually enjoyable to listen to.

  • @haiderbokhari1
    @haiderbokhari1 4 года назад +6

    Amazing tutoring as always! Keep these videos coming!! They're making a world of a difference to my (currently limited) VBA skills.
    I had a thought, would you consider doing a video on how to use VBA generically? Like copy+paste files across different folders, or using VBA to send a standard email message? Not pushing for this but thought it could be interesting. Thanks!!

  • @gonzaortin739
    @gonzaortin739 Год назад +8

    The information you give us is so clean, easy-to-understand and implement… I just love your channel, Im hoping to buy the handbook soon

  • @jastonkong1409
    @jastonkong1409 3 года назад +1

    Clear and concise, I love it!!!

  • @Mandelbrot567
    @Mandelbrot567 4 года назад +1

    I have done some of this before, but not the resize aspect. Great tips, thanks Paul.

  • @cortinas54
    @cortinas54 4 года назад +4

    as always all your videos are amaizing and greats!

  • @manassehkisame6286
    @manassehkisame6286 2 года назад

    This video got me up a high wall...by making my code cut thru a dead end(error) and in a fast way...Genius!

  • @minhphan3580
    @minhphan3580 4 года назад

    You sir, are next level. AMAZING!!!

  • @EduardoRibeiroEdu
    @EduardoRibeiroEdu 4 года назад

    Thanks Man! you and Leila are the best in excel tips!

  • @peajayjay3622
    @peajayjay3622 Год назад

    Absolutely loved this tutorial! Thank you sir!

  • @redfeather22sa
    @redfeather22sa Год назад

    Best Video on the Interweb , Internet & Galaxy !! Star Paul !! Your an Amazing Star !!

  • @franciscovwilliams
    @franciscovwilliams 4 года назад

    Amazing explanation! Congrats!

  • @andrewbeeby2887
    @andrewbeeby2887 4 года назад +1

    Great VBA teacher, I've tried various different tutorials and keep coming back here!

  • @b3lg4r4th8
    @b3lg4r4th8 4 года назад +2

    Excellent video.I can see the value of arrays, as opposed to ranges, and am in the process of changing one of my user forms.However, what the video does not cover and I am interested in is the following:Placing the data from the user form back into the table/spreadsheet.

  • @Akens888
    @Akens888 4 года назад

    Thanks for uploading this Paul.

  • @SuiGenerisGuy
    @SuiGenerisGuy 4 года назад

    I stumbled upon something quite interesting when playing around with this. If you try to set an array, it will return the properties of each cell in a range instead of the value of the cells in the range. Very useful to get a number of properties information

    • @Excelmacromastery
      @Excelmacromastery  4 года назад

      If you use Set with a variant to a range it will return the range rather than the array.

  • @Victor-ol1lo
    @Victor-ol1lo 4 года назад

    Great video !! Thanks for sharing with us !

  • @smanzoli
    @smanzoli 2 года назад

    Thaks!!! Have just changed the code in one of my macros to use arrays. I go through 200k lines in a table. Before, it took 3m20s, now it finishes in 12s, 16x faster!

  • @MGE0007
    @MGE0007 3 года назад

    Good stuff.... taking baby steps with my VBA project but every step is in the right direction with these videos!!... (oh and of course I have liked this video!)..

  • @frikduplessis3869
    @frikduplessis3869 4 года назад

    Thank you Paul a brilliant video again,

  • @donbogdala5428
    @donbogdala5428 Месяц назад

    Awesome work!

  • @mangobrother
    @mangobrother 4 года назад

    Thank you so much. Great video. I am learning a lot. Very useful tips.

  • @Neckbeef82
    @Neckbeef82 Год назад +1

    Has to be the best vba tutorial I've seen on RUclips. Lots of garbage stuff out there. I'm a self taught VBA user, picked up a few very helpful codes and ideas watching this. Thank you

  • @veebee3969
    @veebee3969 Год назад

    Thank you. Great video.

  • @alexkim7270
    @alexkim7270 4 года назад +1

    Thank you so much! This is great.

  • @csemanate
    @csemanate 4 года назад

    Learning a lot. Thanks!!

  • @RyuBeach
    @RyuBeach 4 месяца назад

    설명감사합니다

  • @danielgomezmendoza4851
    @danielgomezmendoza4851 Год назад

    You helped so much, thank you!

  • @Ts18762
    @Ts18762 Год назад

    Mindblowing 💯💯

  • @redangrybird7564
    @redangrybird7564 Год назад

    Mr Kelly, you are a champion 🏆 😎👍

  • @niczoom
    @niczoom 3 года назад

    Great tips, thanks!

  • @vijaysahal4556
    @vijaysahal4556 4 года назад

    superb sir

  • @MrAshfaqahmed
    @MrAshfaqahmed 3 года назад

    Great work Sir, you real world examples are so fascinating. I have a question to in the same situation.

  • @rrrprogram8667
    @rrrprogram8667 4 года назад

    Awesome paul.... U r the master of vba... Great to have u as a teacher

  • @1yyymmmddd
    @1yyymmmddd 4 года назад

    Great video ! Thanks !!!

  • @davidlinton4127
    @davidlinton4127 3 года назад

    Great stuff Paul, big fan From Florida USA....

  • @hericklenin
    @hericklenin 4 года назад +1

    Thanks a lot, this is awesome.

  • @choijaeho653
    @choijaeho653 2 года назад

    Thank you so much for the very useful tips using arrays in vba!! :)

  • @sonderfall1979
    @sonderfall1979 4 года назад +1

    BEST VBA ADVICE EVER!!!! Wow, you are awesome :-)

  • @scotolivera8207
    @scotolivera8207 4 года назад

    Amazing teacher, each video I watch I learn a new trick. Thanks a lot

  • @godisalmighty4449
    @godisalmighty4449 Год назад

    Excellent

  • @chandrachurdatta5844
    @chandrachurdatta5844 2 года назад

    20 Minutes to 33 seconds!!! Thank you very much.

  • @garyknight6766
    @garyknight6766 4 года назад

    Always great stuff, very well presented

  • @mahdizahzah51
    @mahdizahzah51 4 года назад +2

    Mille merci Mr
    Malgré que je suis très faible en anglais mais j'essaye le maximum de vous suivre car je sais bien que votre vidéo est très utile

    • @BabyBugBug
      @BabyBugBug 4 года назад

      mahdi zahzah je vous applaudis d’avoir pris le temps pour comprendre ce qui n’est évidement pas facile à apprendre surtout en une autre langue. Continuez de faire de votre mieux et je vous assure que vous réussirez!

  • @shumzbeazley7056
    @shumzbeazley7056 3 года назад

    Thank you 💜

  • @Deepti1512
    @Deepti1512 9 месяцев назад

    Very nice explanation..... keep it up ....

  • @entropyincrease1
    @entropyincrease1 2 года назад

    You're a beast. Your content is the best.

  • @ghalebevaldo4416
    @ghalebevaldo4416 3 года назад

    Great,thanx

  • @fritzbaden8085
    @fritzbaden8085 3 года назад

    This guy is a frickin' genius.

  • @petermaina7111
    @petermaina7111 3 года назад

    you are a G.O.A.T. probably also take us through append

  • @stevennye5075
    @stevennye5075 4 года назад

    very useful

  • @eduarchavarria
    @eduarchavarria 4 года назад +2

    This is a fascinating topic. I think I can adapt this to copying non-contiguous ranges from one workbook to another, but I'm not quite sure.

  • @adammorait7429
    @adammorait7429 3 года назад

    Many thanks, excellent and well explained, it is crystal clear, your video helped me a lot.

  • @jeffgrant6004
    @jeffgrant6004 Год назад

    Fatastic video. Thanks

  • @user-yk2sg5pd5g
    @user-yk2sg5pd5g 4 года назад

    Paul, Thank you for great instruction. Is it possible if I do samething with a recordset pulled out of query?

  • @jawalim1996
    @jawalim1996 3 года назад

    amazing video, thanks, you are my best vba mastery legend.

  • @tymothylim6550
    @tymothylim6550 4 года назад

    Thank you for the video :) It was helpful for me.

  • @121960864
    @121960864 2 дня назад

    thank you very much!

  • @victormln1214
    @victormln1214 3 года назад

    EXCELLENT SUPER

  • @priyankagupta951
    @priyankagupta951 3 года назад

    A million thank you, could you please suggest if we substarct same value what you have mention but I want to add column in the end and calculation value mention . Can we do that?

  • @kman3d
    @kman3d 2 года назад +1

    Thank you Paul! I was wondering if it is possible to get other cell attributes (like cell background color) and not only cell value into an array ( without iterating through the entire range)? I have a very large range which I need to get the background colors of each cell, and it takea very long to run...

  • @TheJaebeomPark
    @TheJaebeomPark 3 года назад

    Awesome!

  • @hemant0088
    @hemant0088 4 года назад

    Awesome content. Keep sharing useful tips and tricks.
    It is much helpful for developers life. :) :)

  • @gd6noob
    @gd6noob 3 года назад

    Always loved watching your videos.
    Just a quick question.
    How can I adjust this to lets say I want Columns A, C to E.

  • @satishk2410
    @satishk2410 4 года назад +2

    Really awsem, never seen such effective and shorter code in my life, again thanks for creating this video, love you, really helped me a lot

  • @shrutikadongre1046
    @shrutikadongre1046 2 года назад

    Thankyou so much for this tutorial, really helped me a lot! and saved my time.. thanks a lot yet again!! :))

  • @shaikhaziz9703
    @shaikhaziz9703 3 года назад

    this is on fire guys...the arrays functions can makes us our projects much easier and fastest....i am also trying to learning this arrays functions codings,....can someone pls explain me why the sir has used i,1 and i,5 in 6:43 minutes
    i want to use count of columns so what would be just basic formula for counting columns in arrays.

  • @shafiqarzayeva8799
    @shafiqarzayeva8799 4 года назад

    Thanks a lot!!!))

  • @NabhdeepBansal
    @NabhdeepBansal 3 года назад

    Hello. Wonderful lecture! Thanks.
    My question: is there a way by which I store my database table in an array when my workbook opens AND use/call the array at different times wherever required??

  • @Imobajuda
    @Imobajuda 4 года назад

    Excellent video.!!!!!!!!!!!!!

  • @harrys1176
    @harrys1176 4 года назад

    What a legend

  • @muhammadnauman3048
    @muhammadnauman3048 4 года назад

    Great

  • @javedahmed8343
    @javedahmed8343 2 года назад

    Nice

  • @domenicoieracitano2138
    @domenicoieracitano2138 Год назад

    Why does this have only 69k views? It should be on the top of the recommendations on RUclips!

  • @mthwmwn7844
    @mthwmwn7844 3 года назад

    Great video as usual. Quick one. I've been coding VBA for approx 5 years and consider myself a moderate to advanced user. One thing I encounter when setting ranges and pasting arrays back it pastes values and I loose formulas. Is there a method of inputting formulas into the array when it is pasting back out?

  • @gianludisc7148
    @gianludisc7148 3 года назад

    Yooo this is sick

  • @verkar1965
    @verkar1965 4 года назад

    hi thanks for your videos... is it possible to redim preserve arr(1 to x,1) when arr is a variant ? thanks

  • @alesloom
    @alesloom 4 года назад

    Thank you very much. I have a question: what is the best way to delete a row of data from array without changing the range

  • @bonniebaker6226
    @bonniebaker6226 2 года назад

    Loving your videos. A lot of my data is in word documents and I want to use VBA to move it to excel. Is there a similar way to copy a word table into an array without looping through all cells or using a copy/paste command?

  • @jurijdmitrenko5753
    @jurijdmitrenko5753 4 года назад

    Wau, it is very very good 👍😲

  • @BeingUnknown
    @BeingUnknown 3 года назад

    Really awesome! Never seen such effective and shorter code in my life, again thanks for creating this video, love you, really helped me a lot!!

  • @renenielsenring1037
    @renenielsenring1037 4 года назад

    Wow, thanks 😊😊

  • @israelgonzalez677
    @israelgonzalez677 2 года назад

    Awesome! Can we access to the cell properties and methods within the array?