Тёмный

VBA to BROWSE & COPY Data from SELECTED File in Excel 

Leila Gharani
Подписаться 2,6 млн
Просмотров 322 тыс.
50% 1

Join 400,000+ professionals in our courses here 👉 link.xelplus.com/yt-d-all-cou...
Use this simple Excel VBA macro to allow the user to browse for the file they need to import or copy the data from. They will get Excel's open File Dialog Box and they can browse and select the workbook to copy the data from. We use VBA GetOpenFilename method to Open the workbook selected in the background, copy the data and then close the workbook. The user will not even realize the other workbook was opened in the background.
⬇️ DOWNLOAD the workbook here: pages.xelplus.com/vba-select-...
I will also show you how to avoid getting the message "method getopenfilename of '_application' failed". This is a common error when using the application.getopenfilename method and it can easily be avoided by declaring the correct variable type.
👩‍💻 What You'll Learn:
- User Flexibility with GetOpenFileName: Understand how to allow users to select files via Excel's Open dialog box.
- Efficient File Handling in VBA: Learn to open, import, and manipulate data from selected files without hardcoding paths.
- Practical Example: Follow a step-by-step guide to open a file, copy a range, and paste it into a designated area in your workbook.
- Multi-Selection Feature: Discover how to handle multiple file selections for bulk data processing.
🔥 Key Takeaways:
- Customizable File Paths: Free yourself from fixed file paths in VBA code or Excel cells.
- Simple Yet Powerful: Leverage the simplicity of the method for complex file handling tasks.
- Error Handling: Understand how to manage user cancellations and incorrect file selections.
You can expand on this Excel macro to copy data from multiple ranges or multiple sheets or create dynamic ranges.
Check out the FULL 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!
#excel #ExcelVBA

Опубликовано:

 

25 сен 2019

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 359   
@LeilaGharani
@LeilaGharani 5 месяцев назад
Grab the file I used in the video from here 👉 pages.xelplus.com/vba-select-file
@ronvds4713
@ronvds4713 4 года назад
Most people I deal with look at spreadsheets as a glorified calculator and are amazed at what I do for them. And then you come along and I am amazed.
@LeilaGharani
@LeilaGharani 4 года назад
I'm glad I can still surprise you :)
@djdisasterjames
@djdisasterjames 4 года назад
These lessons are so awesome, you really dive into every little detail and explain it so clearly :) Dim as String --> False = "False". Dim as Variant --> False = False :D I was baffled by that once, no doubt others also benefited from this!
@LeilaGharani
@LeilaGharani 4 года назад
I'm glad the tutorials are helpful for you James.
@lephterisp
@lephterisp 4 года назад
A whole new(amazing) world hidden behide Excel .Learning VBA is the next target for me.Thanks again for all you give to us .
@shabbirkanchwala-abwaab6263
@shabbirkanchwala-abwaab6263 4 года назад
Very useful hints B4 I never thought that such can be done in excel I always gain a lots of practical knowledge from your Vdo Simply U R Gr8!!!
@craiggibson8547
@craiggibson8547 4 года назад
I’m doing the VBA course at the 😆moment. Very impressive, well structured and well explained stuff. Great job Leila 👍
@LeilaGharani
@LeilaGharani 4 года назад
That's great Craig. I'm glad you like the course. Many thanks for the feedback!
@Thurmanatr16
@Thurmanatr16 4 года назад
Never a dull video! 🙂Thank you for sharing your expertise with Analysts across the Corporate world. 😃
@LeilaGharani
@LeilaGharani 4 года назад
I'm glad if my videos are helpful in the corporate world :)
@olibolivar7223
@olibolivar7223 4 года назад
I really learn new things every time I watch your videos. Thanks a lot! :D
@lifeinfluenceramitkachalia
@lifeinfluenceramitkachalia 4 года назад
Hi Leila. This video has really helped in one of my excel project of my process flow. I sincerely appreciate you for making this video. I would have loved to share my automation made out of this information, but, considering confidentialty, not possible. Thanks again for making and sharing. Will also go through your other videos.
@merbouni
@merbouni 4 года назад
Well, in less than a year, you've become the number one as reference ... Everything is useful in your RU-vid channel..😍
@LeilaGharani
@LeilaGharani 4 года назад
Thank you, that makes me very happy :)
@andyoverington712
@andyoverington712 3 года назад
Thank you. Finally someone who explains this stuff very well?
@matthewmusselwhite591
@matthewmusselwhite591 Год назад
You are truly amazing and a very gifted teacher. Thank you for all you do!!
@mellowkoopa
@mellowkoopa 4 года назад
This came up in my Google news feed, like sweet nectar of information magic'd down from the heavens to solve a problem I didn't know I had. Thank you so much for your very clear and concise tutorial. Subscribed.
@LeilaGharani
@LeilaGharani 4 года назад
You're very welcome. I'm glad to have you here.
@hddevani
@hddevani 4 года назад
As always, excellent Top-Notch Pure explanation...
@smohanv
@smohanv 4 года назад
This is a kind of VBA idea i was searching for. Thanks. I have subscribed to this channel as well. Thanks a million.
@LeilaGharani
@LeilaGharani 4 года назад
Glad to help. It's great to have you here.
@vishalpatil4102
@vishalpatil4102 3 года назад
Thank you for the valuable information, i have purchased all of your courses from udemy. They are so very helpful
@Matt-zp9jg
@Matt-zp9jg 3 года назад
For those wanting their copied range to be a bit more dynamic use this. OpenBook.Sheets(1).Range("A2").Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select Selection.Copy The only problem with this is it stops if there are any empty rows. So make sure to check your data! LastRow = Sheets(1).Cells(Sheets(1).Rows.Count, StartCell.Column).End(xlUp).Row LastColumn = Sheets(1).Cells(StartCell.Row, Sheets(1).Columns.Count).End(xlToLeft).Column Sheets(1).Range(StartCell, Sheets(1).Cells(LastRow, LastColumn)).Copy This code on the other hand will work and count data even if there any empty rows between data. I'm still trying to incorporate this code into her macro to work so far no luck haha!
@danieljosiahquijano5659
@danieljosiahquijano5659 Год назад
ThisWorkbook.Worksheets("HW15").Range("A1").PasteSpecial xlPasteAll At this part, I am encountering error, that highlights this as yellow. Can somebody help? While my colleague uses the same code, but works fine.
@Matt-zp9jg
@Matt-zp9jg Год назад
@@danieljosiahquijano5659 Could be many things: possible your code has not selected anything to copy. Paste will fail if nothing copied. Your range is different than your paste area. Also better to use this: high lighting entire column a even Blanks. Dim rng As Range Set rng = Range("A2", Range("A" & Rows.count.End(xlup).Address) rng.Copy Range("B2").PasteSpecial xlPasteAll
@johnhayse7147
@johnhayse7147 Год назад
@@danieljosiahquijano5659 Did you figure it out? I'm have the same problem :/
@danieljosiahquijano5659
@danieljosiahquijano5659 Год назад
@@johnhayse7147 I did, when you are recording a macro, under "Store macro in", select dropdown "This Workbook". it is a very specific code.
@johnhayse7147
@johnhayse7147 Год назад
@@danieljosiahquijano5659 Thanks!
@ashrafgharsan553
@ashrafgharsan553 3 года назад
Very useful and practical. Thank you for the great material!
@dhruvakerkar6956
@dhruvakerkar6956 3 года назад
Wow I was actually using "Path" option in excel all this long...this really help...Thanks
@MrKallemyran
@MrKallemyran 4 года назад
This is something I'll actually use so thank you. And also You strike me as very pedagogical so I'll have a look-see if your courses are something i can take parallel to my work.. Fascinated by excels power. Mostly becaus it lets me "program" some simple things without the need to upgrade my IT security clearance in the organisation. As long as I'm within excel boarders. I'm allowed to build "smartnes" 💡
@LeilaGharani
@LeilaGharani 4 года назад
I know exactly what you mean Thomas. Been in the corporate world myself for quite a while trying to navigate around the IT guidelines :)
@MrKallemyran
@MrKallemyran 4 года назад
@@LeilaGharani ha ha Don't say it so loud ;) anyway... I have enrolled.. Now I have to find some time ⏳
@spunjbom
@spunjbom 4 года назад
Awesome job, Leila! I can see myself using this in the future.
@LeilaGharani
@LeilaGharani 4 года назад
That's good to hear Bobby.
@JG-fg1ye
@JG-fg1ye 4 года назад
excel-lent as always, Leila is stunning 👍🏻
@kurtauerbach5883
@kurtauerbach5883 2 года назад
Thanks this really helped me out. Clear and not boring!
@sasavienne
@sasavienne 4 года назад
Excellent.. Thank you very much for sharing your valuable knowledge with us Leila. 👍 👏 🌟
@LeilaGharani
@LeilaGharani 4 года назад
You're very welcome. Glad you like it.
@tha2irtalib343
@tha2irtalib343 4 года назад
beautiful mind , and good teacher , thank you leila .
@craiggibson8547
@craiggibson8547 4 года назад
@tha2ir Talib beautiful teacher, and good mind, thank you leila .
@GrahamSchroder
@GrahamSchroder 3 года назад
Your channel is brilliant! I learn so much. Thanks!
@LeilaGharani
@LeilaGharani 3 года назад
Happy to hear that!
@FanJapanStudios
@FanJapanStudios 4 года назад
Best 👏 Channel 👏 EVER!!! 👏
@Things-Recycleing
@Things-Recycleing 4 года назад
Thanks for usual support in Excel every day learn new topic
@gutobrasiliabrasil
@gutobrasiliabrasil 2 года назад
Great!!! It is exactly what I was looking for!!! You are the best!!!
@shrutiagarwal936
@shrutiagarwal936 4 года назад
Hi, i really like how easily and precisely you explain things. I have a query though, what should i do if i want to get data by opening a link which is a link to excel sheet and not from any worksheet which is saved in my PC.
@vengamanaidu996
@vengamanaidu996 4 года назад
You are my teacher madam, i learned lot from you
@augustodemelo915
@augustodemelo915 3 года назад
It is great!!! Thank you so much for this very valuable information.
@olibolivar7223
@olibolivar7223 4 года назад
Woah! Just what I needed. Thanks! :D
@jmstampe
@jmstampe 4 года назад
Between this and ADO....these are my two faves to impress the non-technical
@stephanie_ong
@stephanie_ong 3 года назад
Thanks! I was able to use your method perfectly :)
@arere9948
@arere9948 9 месяцев назад
TYSM for such an informative instruction, help me a lot 🥰
@prakharsrivastava7795
@prakharsrivastava7795 Год назад
Thank you so much!! Extremely helpful video!!
@thomasfetter
@thomasfetter 10 месяцев назад
you are just awesome
@nielskock3221
@nielskock3221 4 года назад
absolutely awesome thanks. Actually just what I was looking for thanks!
@LeilaGharani
@LeilaGharani 4 года назад
My pleasure Niels. Glad to help.
@twgrisham
@twgrisham 4 года назад
Well done. Very easy to follow and understand. How would handle a dynamic range in OpenBook?
@mhmdseadawy8228
@mhmdseadawy8228 2 года назад
Thanks for this useful lesson, you are the best 👏👏
@johnborg5419
@johnborg5419 4 года назад
Wish I could do that :) :) I am enrolling to your course for sure.
@civilworks3591
@civilworks3591 4 года назад
hi, thank you for lots of tutorials you made. appreciate if you continue or added the program to paste on the last row please. TIA.
@michelacosta9886
@michelacosta9886 Год назад
Very good Leila!!! than ks for this video!!!
@jaypeehernandez4029
@jaypeehernandez4029 4 года назад
Amazing as always.
@alexpspa60
@alexpspa60 2 месяца назад
amazing!!! do you have a video on how to import multiple files?! 😊
@wayneedmondson1065
@wayneedmondson1065 2 года назад
Hi Leila. Great tutorial! Thanks for sharing this :)) Thumbs up!!
@LeilaGharani
@LeilaGharani 2 года назад
Thank you! Cheers!
@youzaist
@youzaist 4 года назад
You are the best ever.... life saver oh my gosh
@rahulbakshi285
@rahulbakshi285 4 года назад
Thanks Leila, I got your VBA videos.
@LeilaGharani
@LeilaGharani 4 года назад
That's great Rahul. Thanks for your support.
@sarfarajkureshi6569
@sarfarajkureshi6569 4 года назад
Nice tutorial mam. God bless you
@joecross5335
@joecross5335 4 года назад
Helpful. I didn't know that method existed.
@samirmohapatra8582
@samirmohapatra8582 Год назад
Very useful ❤. Thank you so much 😊
@ramavtarsingh146
@ramavtarsingh146 Год назад
Very useful thanks a lot, Keep it up.
@excelaficionado
@excelaficionado 4 года назад
Awesome video as always....
@Interphaseable
@Interphaseable 3 года назад
Wonderful video!
@anomolyreport
@anomolyreport 4 года назад
And here I thought openfiledialog and filesystem objects are the only ways to get file names.. Thank you!!
@barejam
@barejam 4 года назад
Excellent! Thank you :)
@titsermon
@titsermon 4 года назад
Very informative. Gonna try it later.
@buradagunta1
@buradagunta1 3 года назад
Hi, this is very helpful. would you explain considering the csv file instead xlsx file, copy data from sheet 1 of csv file opened and paste in the current workbook. Thank you
@spneerajmishra
@spneerajmishra Год назад
Great help thank you 😊
@r2r616
@r2r616 3 года назад
Love it, thanks. Simple and effective. Used it to automate my tax calculations for GME tendies ❤
@homejonny9326
@homejonny9326 4 года назад
Just amazing!!
@Khalnayak_sanju143
@Khalnayak_sanju143 4 года назад
Wow thank you mam ,it's helping me on my work Thanks Once again
@LeilaGharani
@LeilaGharani 4 года назад
My pleasure, glad to help.
@yurd563
@yurd563 4 года назад
Thanks for video!
@esbi1124
@esbi1124 4 года назад
Really good!
@totallycybertechnologies1631
@totallycybertechnologies1631 4 года назад
Fantastic video. Exactly what I need. After the user selects the file, is there a way for the user to select which data he/she would like to copy into cell A10?
@dkb1111
@dkb1111 4 года назад
हर बार कुछ नया ,धन्यवाद लीला
@LeilaGharani
@LeilaGharani 4 года назад
I'm trying my best :)
@farizpatah4081
@farizpatah4081 4 года назад
Finally got this macro.. Thanks a lot...
@LeilaGharani
@LeilaGharani 4 года назад
Glad to help :)
@szebart
@szebart 4 года назад
Incredible, this is exactly what I was just searching for! So much thanks! :))>
@LeilaGharani
@LeilaGharani 4 года назад
My pleasure Bee. Glad to help.
@samehtalaat56
@samehtalaat56 Год назад
Amazing! Really helpful :-)
@francoismarsau6412
@francoismarsau6412 Год назад
Great videos as always. I have signed up for some courses of yours to learm more. You are geat teacher. you mentioned that " and copy specific ranges and import them in our file will be shown later how to do". Can you give example of this or tell me lesson no in you course that explains this as I could not find it. Thank you once again for great courses and video content.
@puranbisht6228
@puranbisht6228 4 года назад
Thanks for the wonderful video. Not a single moment when i felt bored seeing it. Amazing🤗 One doubt🤔, how can we browse and update from two different files.
@mc24bk
@mc24bk Год назад
Great video, very easy to understand. How to copy the entire column A & B without setting a range number?
@nevermind4780
@nevermind4780 4 года назад
another creative ideas ☺👍👌
@chamindabasnayake4844
@chamindabasnayake4844 4 года назад
Great! Thank you Leila!
@LeilaGharani
@LeilaGharani 4 года назад
My pleasure.
@jayeshjamtani924
@jayeshjamtani924 4 года назад
Thank you #LeilaGharani #ExcelQueen for sharing this wonderful way to open files. I am a big fan of yours ( more than of Excel )
@LeilaGharani
@LeilaGharani 4 года назад
I'm happy to hear that :)
@jeandaniel521
@jeandaniel521 2 года назад
Amazing, this saved me so much time :)
@LeilaGharani
@LeilaGharani 2 года назад
Great to hear!
@user-zu5fe9yi2m
@user-zu5fe9yi2m Год назад
BIG THANKS LAILA
@ExcelExciting
@ExcelExciting 4 года назад
Great Video 👍🏻.. thanks for sharing
@LeilaGharani
@LeilaGharani 4 года назад
Thanks for the lightning fast comment Faraz :)
@walelaiouattara4882
@walelaiouattara4882 4 года назад
Thanks, nice and helpfull.
@vaishalikhedlekar3733
@vaishalikhedlekar3733 3 года назад
This is really great !! But would like to understand how can we apply filter on the selected file based on a certain criteria and copy only the filtered data on the macro workbook.
@robertakwasiadjei8223
@robertakwasiadjei8223 4 года назад
Very much grateful Leila.
@LeilaGharani
@LeilaGharani 4 года назад
You're very welcome Robert!
@pablofriedemann5262
@pablofriedemann5262 4 года назад
great video!
@mohdkharish8169
@mohdkharish8169 4 года назад
Thanks a lot.. Awesome.. for next can you update for select file with multiple file.. Thanks
@m1cannas
@m1cannas 2 года назад
You rock the item. Super
@hadiasghari2266
@hadiasghari2266 3 года назад
u r my excel hero
@user-zh7km3ph7b
@user-zh7km3ph7b 3 года назад
Thanks a lot. it is usefully for me
@aguyy222
@aguyy222 4 года назад
Thank you so much!!!!
@juniorcollins
@juniorcollins 3 года назад
Hi Leila, great video. I've being following your videos and you're an awesome teacher. You had mentioned in this video about multiple files. Can you direct me to that video? I have something that's giving me an issue and I want it resolved.
@abdallah.kandiel
@abdallah.kandiel 4 года назад
Happy Thursday your highness This is not fair, you publish your jewels while me at work.😅 I can't return to my firsts💪 Anyways You are the one I'll brb after watching Thanks in advance ♥
@LeilaGharani
@LeilaGharani 4 года назад
First or not I'm always happy to see your comments :)
@user-nm4ul6gr6o
@user-nm4ul6gr6o Год назад
Thank you so much
@michaljurica9642
@michaljurica9642 3 года назад
nice job! thanks :)
@TheJaebeomPark
@TheJaebeomPark 4 года назад
Awesome!
@pedroantas3553
@pedroantas3553 2 года назад
Excelent. Thanks :)
@vpt262
@vpt262 4 года назад
Thank you so much for this video. How can I adopt this script for importing a complete csv file and pasting it in a specific cell?
@swapnilsakpal2504
@swapnilsakpal2504 2 года назад
Awesome video ma'am..much needed. iTs working for me. Thanks a lot. going one step ahead, I've a small huddle. I need to use index match formula within the same code, I tried but failed. Instead of defining the cells from source file. i need macro to use index match function and get the result in active sheet. Could you please assist me. Thank you so much in advance
@gamingstudio9949
@gamingstudio9949 4 года назад
Very nice video
@enriqueblanco8784
@enriqueblanco8784 2 года назад
Thanks for your excel related content. I was wondering, can Google sheets open (and run) excel files containing macros (buttons, for instance)?
@arifhk007
@arifhk007 4 года назад
I like your videos from other youtube videos...Coz your teaching style is very helpful and clear! Thank you, Mam!
@LeilaGharani
@LeilaGharani 4 года назад
I'm very glad to hear that :)
@jonathanjesusdelvillarrebo7429
@jonathanjesusdelvillarrebo7429 4 года назад
Hello good night your video is very well explained, I just wanted to ask a question: How can I make a filter inside the files that opened and copy the data from the filter result?
Далее
How to Create & Use Excel Macros (Real world example)
10:09
The Ultimate Guide to Copying Data using Excel VBA
31:05
Introducing Python in Excel
19:01
Просмотров 1,5 млн
VBA to Browse File and Open File in Excel
5:03
Просмотров 78 тыс.
Learn Excel VBA to Automate Anything
14:02
Просмотров 361 тыс.
How to get the Last Row in VBA(The Right Way!)
15:41
Просмотров 151 тыс.