Save File As (Based on Cell Value) | Excel VBA Macro

preview_player
Показать описание
Excel VBA Macro: Save File As (Based on Cell Value). In this video, we create a macro that filters data and saves file based on cell value. If you ever need to automatically filter data and save a file based on another cell in your workbook, with Excel VBA, you can use the code we write in this video to automatically filter data across pertaining to a value in a cell that can changed, without having to alter the code. The code specifies which worksheet it will be filtering, the starting point for the filtering, and then what cell will be used to filter by. The cell does not have to be on the same worksheet, and we can change the value of the cell as we please and filter by whatever we decide. After the filter is applied, only values that we want to see will be visible: giving you the freedom to change the value you filer by at will; same goes for saving the file. You can save the same file multiple times with different file names by changing the name of the cell value you are referencing. This video shows you the file path as the macro runs so that you can see the file get saved down with the cell value in the file name as well.

Data used in this video:

#ExcelVBA #ExcelMacro
Рекомендации по теме
Комментарии
Автор

Just what I was looking for to finish out 3 days of finding macros and tweaking them and stacking them together to make them work. Then this video closed out the last of my work with only 4 lines of simple code that works flawlessly. I removed the naming and put in something in for the name like C2 & E2 for the name, but had to figure out how to add a space which left me feeling like an idiot when all I had to do was add in C2 & " " & E2 with a space between the quotation marks. Now I can easily break out my task to almost 80 named sheets, reply to the last email, attach the named file, delete that file and go to the next, rinse, wash and repeat until all files are sent and deleted. I wish I could express how much time this saved me as I need to do this with all these spreadsheets every week. This ends flawlessly and closes as it should, and the other two macros for some reason work fine, but fail at the last step as if it is trying to continue a loop and it has nowhere to go for the next loop. Anyway, I have another 130 spreadsheets I can do this for and share with the team.

Troy-Echo
Автор

This is good, thanks! What would be great would be a macro that would filter and save a file once for each unique value in a given column.

To apply this idea to the example data set in this video, what if you ran the macro and it generated a file for each unique region listed in Column B? (And even better if it ONLY saved the values for each region in their corresponding file - not just the same file filtered multiple ways.)

zimmecl
Автор

Hi
Thanks for the video.
Instead of writing the sheet name (Whatever) how do you choose the sheet based on a cell value if the cell value equals the sheet names?

MrKaanbjerg
Автор

Thank you, Great video.
I was just wondering if you could help me. I have 5 sheets and only want to save sheet 1 as new workbook.xlsx file. I do not want the filtering of the data, just save the workbook using the filename path and the cell (2, 6). I am still very new at VBA.

martinemaurizio
Автор

Great video! Really helpful, thank you for sharing

ivanpap
Автор

thank you awesome.
would you be able to help with this - i have 10 tabs with names and data already in them. how can i save each tab into its own sheet and give it a particular name, which is a cell reference within each tab?

mahmooddadhiwala
Автор

Super video this is very much useful, is it possible for us to save those files as PDF instead of excel format?.

karnamannai
Автор

Hi, Wondering if you could do a video that you can click the button and it will run a code where it will print active sheets to pdf, save as based on value in file path and close.
this would be great.

chsproteus
Автор

Hello Sir,
Can you share the VBA code to create .ics files from the data in Excel with different time zones & start & end time and that to be saved in desktop. Please help

devanshgroup