Create Excel Workbooks Worksheets Automatically with Excel VBA Arrays

Join 400,000+ professionals in our courses here 👉 link.xelplus.com/yt-d-all-cou...
Discover how to create a custom Excel workbook using VBA in our step-by-step tutorial. Perfect for beginners and intermediate users, this video guides you through the process of making a workbook with a separate worksheet for each company listed in your Excel sheet.
🎓 Get access to the full Excel VBA course here 👉 www.xelplus.com/course/excel-...
Learn how to:
▪️ Use arrays for efficient data handling.
▪️ Loop through rows and columns to manipulate data.
▪️ Create a new workbook with individual sheets for each company.
▪️ Populate sheets with company and manager names.
🔑 Key Features:
▪️ Easy to Follow: Clear, step-by-step instructions.
▪️ Practical Use of Arrays: Learn to use two-dimensional arrays in Excel VBA.
▪️ Workbook Customization: Automatically create a new workbook with specified data.
▪️ Real-World Example: Apply these techniques to manage company data efficiently.
★ Links to related videos: ★
Learn how to DIM variables in VBA: • How to Declare (Dim) a...
VBA Playlist: • Excel VBA & Macros Tut...
★ 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!
#ExcelVBA

Пікірлер: 85

  • @LeilaGharani
    @LeilaGharani6 ай бұрын

    Get access to the full Excel VBA course here 👉 www.xelplus.com/course/excel-vba-excel-macros/

  • @quasipseudo1
    @quasipseudo14 жыл бұрын

    You explain things well, instead of simply showing off your knowledge. Very good.

  • @stuartboyle5169
    @stuartboyle51695 жыл бұрын

    Leila Nice Job! You are the only video that pops up which is truly working with an Array and not confusing a list of cells for a declared Array.

  • @ExcelForFreelancers
    @ExcelForFreelancers6 жыл бұрын

    Thanks for sharing your knowledge on arrays. Nice job Leila.

  • @sawkyawhtike
    @sawkyawhtike3 жыл бұрын

    The best tutorial on array that I have ever seen. You are great.

  • @petralabui9302
    @petralabui93024 жыл бұрын

    best youtube chanel for excel, simple, easy and right to the point

  • @LeilaGharani

    @LeilaGharani

    4 жыл бұрын

    😘

  • @SolidSnake59
    @SolidSnake594 жыл бұрын

    Hi, I have learned from Paul Kelly that assigning array is much simpler. You can just use such a code: dim arr as Variant arr = Range("A6").CurrentRegion And that's it!

  • @TheFoxwiz

    @TheFoxwiz

    4 жыл бұрын

    That’s exactly what I was thinking

  • @ckokse
    @ckokse6 жыл бұрын

    Thanks for that! Great example and very well explained.

  • @HerculesSantosLoyola
    @HerculesSantosLoyola4 жыл бұрын

    Amei sua aula, você explica muito bem. Tem poucas aulas em português sobre esse conteúdo. Obrigo pela ajuda.

  • @mrashid229
    @mrashid2293 жыл бұрын

    Thank you for the lesson. This teaches how to create 2D arrays. Once learnt, one may try this alternative mean for copying the data from sheet to array(dynamic ). This eliminates declaring some variables, using 2 nested loops and rewriting codes when number of company/manager increases. Dim Compinfo As Variant ' To be used as dynamic array Dim i as Integer ' Following code will create 2D array in Compinfo variable taking the values from range A6:B14 Compinfo = Sheet1.Range("A7").CurrentRegion.Value For i = 2 to UBound(Compinfo , 1) ' Compinfo(i, 1), Compinfo(i, 2) Next i

  • @LeilaGharani

    @LeilaGharani

    3 жыл бұрын

    Great tip!

  • @krn14242
    @krn142426 жыл бұрын

    Thanks. Good example of Array

  • @ian_senior
    @ian_senior6 жыл бұрын

    thanks Leila, extremely helpful and easy to understand. You are a great Instructor and beautiful lady. :)

  • @soberingtimes2362
    @soberingtimes23625 жыл бұрын

    Excellent. Thank you very much :)

  • @wynhopkins4023
    @wynhopkins40236 жыл бұрын

    Well explained on something that can be really tricky

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    Thank you Wyn - nice to see you here :)

  • @pinkeishz9106
    @pinkeishz91066 жыл бұрын

    It was great example of 2 dimensional Array, which was quick well explained... 👌

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    Thank you. Glad you find the explanation easy to follow :)

  • @313rbd
    @313rbd4 жыл бұрын

    Excellent teacher! I also take your courses on Udemy. Well done

  • @mahmoudsabry1244
    @mahmoudsabry12445 жыл бұрын

    Thanks alot you guided me toi much

  • @abdulazizal-jasser7797
    @abdulazizal-jasser779711 күн бұрын

    You can copy the range to the array in one line instead of the loop: CompInfo = Range("A7:B14").Value. Before that you need to declare the array: Dim CompInfo As Variant

  • @mackidson1
    @mackidson15 жыл бұрын

    OMG SHE'S GORGEOUS!!!

  • @muhammetsamkara1074
    @muhammetsamkara10743 жыл бұрын

    Great! VBA Queen

  • @grawzito
    @grawzito5 жыл бұрын

    Excellent. Thank you !

  • @LeilaGharani

    @LeilaGharani

    5 жыл бұрын

    You're very welcome Paulo.

  • @excelisfun
    @excelisfun6 жыл бұрын

    Thanks for the array fun : )

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    You're very welcome Mike.

  • @mujeebuddinsarfaraz
    @mujeebuddinsarfaraz5 жыл бұрын

    Thank you

  • @alexrosen8762
    @alexrosen87626 жыл бұрын

    Sooo useful! Thanks Leila :-)

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    You're very welcome Alex :)

  • @abdullah_alhathloul_
    @abdullah_alhathloul_2 жыл бұрын

    Excellent

  • @sujalbalar316
    @sujalbalar3164 жыл бұрын

    Excellent lady

  • @jaredwhitener4385
    @jaredwhitener43854 жыл бұрын

    Helpful video. I added code at the end of the line for adding a new sheet. "Set ShNew = NewBook.Worksheets.Add(after:=Sheets(Sheets.Count))" This forces the tabs/sheets to be in order. Top to bottom on the list becomes left to right in the sheet order. Also, a line at the end could be added, "Sheets(1).Delete", to get rid of the blank sheet (given you adopted my above code addition for order).

  • @ashishkumar-gd7dh
    @ashishkumar-gd7dh3 жыл бұрын

    i love your videos

  • @ashoksahu9546
    @ashoksahu95466 жыл бұрын

    Very very nice video. Very well explained

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    Thank you Ashok. Glad you find it easy to follow.

  • @rrrprogram8667
    @rrrprogram86676 жыл бұрын

    Great video

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    Thank you. I'm glad you like it.

  • @vijaysahal4556
    @vijaysahal45564 жыл бұрын

    superb ms L

  • @stevennye5075
    @stevennye50754 жыл бұрын

    well done

  • @johnborg6005
    @johnborg60056 жыл бұрын

    Thanks Leila :)

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    You're very welcome John.

  • @hosseinhosseinpoor4845
    @hosseinhosseinpoor48453 жыл бұрын

    thanks.

  • @mohamedbadawy
    @mohamedbadawy6 жыл бұрын

    thank you

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    You're very welcome Mohamed

  • @PrincePedia
    @PrincePedia6 жыл бұрын

    Great

  • @ahrorkuldashev9603
    @ahrorkuldashev96034 жыл бұрын

    Struggling to understand what kind person would give a dislike to this video.

  • @RajaTRemyaR
    @RajaTRemyaR5 жыл бұрын

    Good one. You can use dictionary in VBA which is more useful than array

  • @edihardinal5940
    @edihardinal59404 жыл бұрын

    It's great explanation. I love u Laila.

  • @BillSzysz1
    @BillSzysz16 жыл бұрын

    Thanks Leila for a very clear explanations of building and using arrays in VBA:-)) I know that this is VBA lesson but I would like to throw in my two cents here. This particular case we can do without VBA. I think, in 1 - 1.5 minute :-)) And it doesn't matter how many worksheets we need to add.

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    :) Agree - I wouldn't ever think of writing this code if I had to do this once. if I had to repeat it every week on a larger set, then probably yes...

  • @BillSzysz1

    @BillSzysz1

    6 жыл бұрын

    Absolutely agree, Leila :-))

  • @prakashsrinivasan7840
    @prakashsrinivasan78402 жыл бұрын

    Nice

  • @jaaptijssen1225
    @jaaptijssen12254 жыл бұрын

    Nice video with clear explanation. about creating Array! What exactly are the benefits of using an array.? This is also possible with a loop based on the cell values ​​in Excel. (I am novice... :)) So hence the question, am a novice VBA so I am interested.

  • @manishagrawal417
    @manishagrawal4176 жыл бұрын

    Hi Leila, Your videos are great..really easy to understand and follow..Can you also make a video on how to communicate to microsoft sharepoint via VBA..I am looking for some basic tasks like - Download a file / folder from SP to local drive, Upload file to SP, check for existence of file in particular folder of SP, count the number of files in specific folder of SP, etc

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    Thanks Manish - Glad you find the videos easy to follow. I added this to my list.

  • @bassisessaidexcel
    @bassisessaidexcel5 жыл бұрын

    Merci

  • @LeilaGharani

    @LeilaGharani

    5 жыл бұрын

    My pleasure.

  • @matthewmoses6382
    @matthewmoses63822 жыл бұрын

    Hi Leila, thank you for all your wonderful videos. I am hoping you could help me. I am using vba to and an array to break up a large list of over 300 names I want my array to have a size of 64 names unless the last name in the array matches the 65th name.

  • @deveshkumar2736
    @deveshkumar27365 жыл бұрын

    Hi Leila your videos are really nice my question is that we can do this by loop having 2 variables one will store the company name and second manager and then we can run the loop.. I don't have any knowledge about Ubound and Lbound can you tell.me the difference please please

  • @LeilaGharani

    @LeilaGharani

    5 жыл бұрын

    Yes that will work too. Ubound is the upper limit of the array and Lbound is the lower limit. These are used to get the size of the array.

  • @ismailismaili0071
    @ismailismaili00716 жыл бұрын

    thank you so much Ms. Leila kindly please let me know how to use barcode for the same product and make the qty bar add one as much as you scan the same product hope you understand what i mean. thanks again

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    You're welcome Ismail. Not sure about your query though - best is to post your specific question with a sample file either here: www.mrexcel.com/forum or here: www.excelforum.com/ - you can post a link to your question here too and if I get a chance I can take a look, otherwise you will get answers from others...

  • @Strobinski
    @Strobinski6 жыл бұрын

    CompInfo = Range("A7:B14") works as well to populate the array directly (?)

  • @LeilaGharani

    @LeilaGharani

    6 жыл бұрын

    Thank you for your comment :) Yes - we cover variant arrays separately in the course. The aim here is to be able to visualize a two dimensional array. I find that's easiest to do when referencing rows and columns....

  • @Dubaiinit
    @Dubaiinit4 жыл бұрын

    Spending more time with Leila than with the Mrs.... 8-)

  • @LeilaGharani

    @LeilaGharani

    4 жыл бұрын

    Haha. I hope she'll understand :)

  • @FurryEskimo
    @FurryEskimo2 жыл бұрын

    I don’t suppose we could use strings to refer to data, rather than numbers for the bounds? I have an input which is a strong, and I want to use that as the variable being used to store data in the array. Eg. Input “species=dog”, array(species) = array(species) + 1

  • @pabloalonso1001
    @pabloalonso10015 жыл бұрын

    Hi Leila! Thak you very much for sharing your knowledge on VBA with your superb posts and channel. In particular, I found this one as a great example of 2 dimensional Array. However, code creates worksheets in an inverse order, that is to say, the first one is the "Pes" worksheet, wich is the last one item of the list. I have been trying: For r = 8 To 1 Step -1, but VBA gives me an error. However the same idea works with an 1 dimesional Array. Please, How could I try to obtain worksheets in its order? Thanks a lot...

  • @robertbateman3665

    @robertbateman3665

    4 жыл бұрын

    Pablo Alonso: Try using ...Worksheets.Add(After:=Sheets(Sheets.Count)). This will add the new sheet to the end of the sheet tabs. Note: You'll still have "Sheet1" in the new book. You might want to write something to find if Sheet1 exists & if so, delete it. Have a great day!

  • @mohammadalmomani1193
    @mohammadalmomani11935 жыл бұрын

    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

  • @alvaromorales6828
    @alvaromorales68284 жыл бұрын

    People, don't use for loop, it's not fast. Just equal the range to some array and that's it.

  • @vijaysahal4556
    @vijaysahal45564 жыл бұрын

    👍👍👍👍👍👍👍

  • @sandeepkothari5000
    @sandeepkothari50006 жыл бұрын

    WoW = Wonder Woman = Leila Gharani

  • @poweroff9593
    @poweroff95934 жыл бұрын

    How can check if array array is empty or not because iam get error if ido like this and array not empty Dim arr as variant Arr = range ("A1"). Currentregion. Value If arr =empty then 🌹

  • @yeahnick4260

    @yeahnick4260

    5 ай бұрын

    Dim Arr as variant Arr = Range("A1").CurrentRegion.Value if IsArray(Arr) = True then ( ... ) Else ( ....) end if

  • @VBAbyMBA
    @VBAbyMBA4 жыл бұрын

    I created first button and copy paste it to the Userform but it did not Prompt: "You already have a control Name XXX. Do you want to create a control array?" so my question is how do I create Control array of Command buttons. what are the steps to follow? Am I missing something? I am new to this Topic Please help

  • @jafarmiya9213
    @jafarmiya92134 жыл бұрын

    Hi mam how can it make Dynamic?

  • @saileshmutreja9311
    @saileshmutreja93116 жыл бұрын

    Aswm

  • @bigsam1989
    @bigsam19894 жыл бұрын

    Please how can I convert a List of cells to an Array e.g A 1 by 9 to a 3 by 3 array arrangement, such that the Array is linked to the List Data? Something like this- 1 2 3 4 5 6 7 8 9 To 123 456 789

  • @Permaclok

    @Permaclok

    3 жыл бұрын

    i = 1 For j = 1 to 9 Arr(i,j) = cells(1,j) If(j / i > 3) then i=i+1 End if Next j

  • @kalpeshparkar9852
    @kalpeshparkar98523 жыл бұрын

    May I get your email id need a help in VBA application development