How to Use Arrays Instead of Ranges in Excel VBA

Поділитися
Вставка
  • Опубліковано 12 січ 2025

КОМЕНТАРІ • 265

  • @Excelmacromastery
    @Excelmacromastery  6 місяців тому

    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 .

  • @BenjaminHouot
    @BenjaminHouot 5 років тому +57

    Best vba channel i ever found !

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

  • @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.

  • @redfeather22sa
    @redfeather22sa 2 роки тому +1

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

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

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

  • @Neckbeef82
    @Neckbeef82 2 роки тому +1

    Has to be the best vba tutorial I've seen on UA-cam. 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

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

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

  • @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...

  • @mike_case
    @mike_case 5 років тому +9

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

  • @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!

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

    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.

  • @natejewkes
    @natejewkes 4 роки тому +3

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

  • @luisdmoreyra
    @luisdmoreyra 3 роки тому +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!!

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

    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!

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

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

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

    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!)..

  • @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.

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

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

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

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

  • @krn14242
    @krn14242 5 років тому +2

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

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

    Mr Kelly, you are a champion 🏆 😎👍

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

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

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

    Clear and concise, I love it!!!

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

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

  • @Mandelbrot567
    @Mandelbrot567 5 років тому +1

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

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

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

  • @cortinas54
    @cortinas54 5 років тому +4

    as always all your videos are amaizing and greats!

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

    Absolutely loved this tutorial! Thank you sir!

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

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

  • @m-squaredcontractors9720
    @m-squaredcontractors9720 5 років тому +1

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

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

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

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

      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!

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

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

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

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

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

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

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

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

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

    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.

  • @donbogdala5428
    @donbogdala5428 7 місяців тому

    Awesome work!

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

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

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

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

    Thank you for what you have taught, see if it is possible with an array to load a listbox with more faith than 10 columns faster??? greetings

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    This guy is a frickin' genius.

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

    Mindblowing 💯💯

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

    This is really really great and has reduce the processing speed of my code dramatically. The only issue that I have encountered is writing the data back to the same location (I am pulling the data from an Excel table) that is filtered. I see very strange results where the first row of the array is inserted into the last line that is displayed. Any suggestions on how to paste back to a range / table that is filtered? I could remove the filter and then re-apply it, but if that data that is changed in the array, then the same filter would not be applied.

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

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

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

    Thank you. Great video.

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

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

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

    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?

  • @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.

  • @kman3d
    @kman3d 3 роки тому +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...

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

    Paul this is awesome. Can this be used in Class Module. if not please show us how to do it. Thanks in advance.

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

    06:49 - Was Wow--- In one line we can paste the range that we work on

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

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

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

    A query, in an array (not in excel cells) is it possible to include background color? or put background color to certain elements of that array?

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

    Thanks for uploading this Paul.

  • @ProgressiveEconomicsSupporter

    Hey Paul, amazing Tutorials of yours!! Will this code also adapt to added rows within oder at the end of the original table, as it does with added rows?🙏😎🇩🇪

  • @kartickchakraborty9135
    @kartickchakraborty9135 Місяць тому

    Your explanation is superb. No one can explain these topics so easily. Sir, would you kindly please make a video on this topic - "How to split Strings that contain no Delimiter using User Defined Function in Excel VBA?" For Example, - You have some client names on your Sheet1 from Range("A2") to Range("A16"):
    Raw Data:
    ========
    Names First Names | Middle Names | Last Names
    ------------ -------------------- ------------------------ --------------------
    AlexanderWilliamJamesBrown
    AmandaTaylor
    AriaNguyen
    AubreyFoster
    AveryAnnPhillips
    Beerus
    BenjaminThomasHarris
    CharlotteMitchell
    ChristopherJackson
    DanielJamesMiller
    DavidAndrewJohnWilliams
    Dende
    DylanJamesWard
    ElijahWatson
    EllaSophiaRoberts
    ==========
    Here, some clients have First Names, Middle Names and Last Names (For Example: Alexander William James Brown etc.); some have First Names and Last Names (For Example: Amanda Taylor etc.) and some have only First Names (For Example: Beerus etc.). Now, I want to delimitate each name based on the Capital Letter. Desired Output mentioned below:
    Desired Output:
    =============
    Names First Names | Middle Names | Last Names
    ------------ -------------------- ------------------------ --------------------
    AlexanderWilliamJamesBrown Alexander | William James | Brown
    AmandaTaylor Amanda | | Taylor
    AriaNguyen Aria | | Nguyen
    AubreyFoster Aubrey | | Foster
    AveryAnnPhillips Avery | Ann | Phillips
    Beerus Beerus
    BenjaminThomasHarris Benjamin | Thomas | Harris
    CharlotteMitchell Charlotte | | Mitchell
    ChristopherJackson Christopher | | Jackson
    DanielJamesMiller Daniel | James | Miller
    DavidAndrewJohnWilliams David | Andrew John | Williams
    Dende Dende
    DylanJamesWard Dylan | James | Ward
    ElijahWatson Elijah | | Watson
    EllaSophiaRoberts Ella | Sophia | Roberts

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

    First of all. Thank you for taking VBA to a whole new level! These videos are great. I got stuck at the code at 3:14 . VBA says gives a compile error: "Variable Not Found" for "shData". Any idea why it is working for you but not mine? VBA version is 7.1.

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

      I figured it you. Looks like you are referencing the sheet name under Microsoft excel objects.

  • @Victor-ol1lo
    @Victor-ol1lo 5 років тому

    Great video !! Thanks for sharing with us !

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

    Amazing explanation! Congrats!

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

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

  • @힐베르토
    @힐베르토 5 років тому

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

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

    Thank you Paul a brilliant video again,

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

    Always great stuff, very well presented

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

    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!!

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

    Learning a lot. Thanks!!

  • @imboom-
    @imboom- Рік тому

    Thanks for the video, Paul! I had a question! I'm looking to copy all the info from a sheet and paste it to another sheet. Based off the indent value of a second column, I will offset it on a row in the new sheet(higher indent = higher offset, indentlevel 1 goes to A:D on row 1, indentlevel 2 goes E:H on row 2, ect) then continue through the entire sheet. I'm seeing if I can apply this to that but the problem is my first row has an embedded link.. is there a way to add that into the array and keep the link as well when it gets pasted?

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

    Great tips, thanks!

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

    Fatastic video. Thanks

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

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

    You sir, are next level. AMAZING!!!

  • @alexkim7270
    @alexkim7270 5 років тому +1

    Thank you so much! This is great.

  • @chrish281
    @chrish281 5 років тому +1

    I'm far from a newb with VBA and I'm still learning some things I didn't know from your vids, thanks! Question : I see you use .value I have always been told to use value2 because it is allegedly faster and gives the underlying value...thoughts?

    • @Excelmacromastery
      @Excelmacromastery  5 років тому +2

      I use Value for almost everything and I never have a problem. There may be specific cases where you need it:
      "The only difference between this property and the Value property is that the Value2 property doesn't use the Currency and Date data types." -docs.microsoft.com/en-us/office/vba/api/excel.range.value2

    • @dougdevine27
      @dougdevine27 5 років тому +2

      Value2 seems to be faster (for all types) and safer (for currencies and dates):
      fastexcel.wordpress.com/2011/11/30/text-vs-value-vs-value2-slow-text-and-how-to-avoid-it/
      I recreated the analysis in that blog with similar favorable metrics for Value2 over Value.

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

      ​@@dougdevine27 Thanks, good link...I'll stick to using value2...but I'm sure for most real world cases it makes little difference

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

    I know this video is old. But want to ask this question of you or anyone who reads it. Is there an equivalent query-generating function/feature for Excel like there is for MS Access? That one is so slick and easy to use. I want to have a table of categories with multiple columns from which criteria can be set to filter only those that meet or exclude them. I don't see a way to easily do that in Excel. If not, can you create a video on how that's done? Thanks.

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

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

  • @121960864
    @121960864 6 місяців тому

    thank you very much!

  • @RICARDOHERNANDEZ-rf3ug
    @RICARDOHERNANDEZ-rf3ug 2 роки тому +1

    Hello i have one column that contains filenames in unicode, but when i assign the range to the array, the array don't have the true filename, it seems like be in ansi encoding, what can i do in order to get the true names in the array?

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

    Is there an effective way to use the same array approach to also copy and transfer the cell format to the new range?

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

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

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

  • @WieEiPiehGuy
    @WieEiPiehGuy 5 років тому +2

    Thanks, very informative. I have a question though: How do I manage to format my cells to achieve a good layout? My current Excel sheet is rather slow as I copy a row and insert it, but with this (slow) technique I don't have to care about number/text/date/currency formats or cell formats (yellow background, bold numbers) etc. as Excel takes care of that for me. Should I work with arrays and after my "tables" are filled with data, another macro formats the cells according to my wishes? Or is there another approach?

    • @WieEiPiehGuy
      @WieEiPiehGuy 5 років тому +1

      I "tweaked" my Excel spreadsheet and was able to speed up the operations by a factor of 17 (of course, I did not use 'select' and similar bad techniques from the start). I did this by using arrays and, instead of adding one row per operation, added all the needed rows at once and inserted the array contents into those empty with one go. The format of the cells (styles, number formats, borders...) is fixed at the end for the entire "table". Thanks :)

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

    Hello Sir, can you help me? I really need your help in coding (including more Listbox to 1Listbox) .Listbox1 (10row and 15column) and Listbox2 (10row and 15column) and Listbox3 (10row and 15column) addTo Listbox4 (30row and 15column). Thank you for all the guidance

  • @ShivaKumar-xo4hw
    @ShivaKumar-xo4hw 4 роки тому

    Thanks for your Awesome Video Sir. We are selecting the around 5 columns in array and copy, pasting it to different columns arr with same 5 columns. But I have different scenario. So my question is can I select 5 columns in array, copy, paste only any 3 column Eg. Column A, B, E.. Only by using array. Please help me Or Give me alternate idea

  • @hericklenin
    @hericklenin 5 років тому +1

    Thanks a lot, this is awesome.

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

    Can you have a UDF in an Add-in and extract information from a named range within the same Add-in from one of the internal worksheets? Or is the vba module the only part of the Add-in that can be used/accessed?

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

    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?

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

    thanks paul - one question - how would you use array if you want to grab ranges that are not congruent (i.e. range(a:a), range(c:c), etc.) in one go? it seems that array = range doesn't like this. i've tried to use union to do that but no luck.

  • @kanjenplays3946
    @kanjenplays3946 10 місяців тому

    Hello, Thanks for this tutorial. However, my problem here is that it can't include data after blank row or blank column. Any tips? Thanks

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

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