I would like to create a series of folders in explorer using a range of cells A1:A162 for the names of the folders. Wondering if there is a way that I can automate this using VBA versus doing it manually .
I want it to return the subfolders from a named folder, but only the folder name, right now it returns the whole path. So my code has to then text to column that path, then delete the columns I don't need. Is there a way to shorten this? Here is my code so far:
'Lists Folders' Worksheets(1).Range("A3:A300").Value = ClearContents Worksheets(1).Activate Dim row As Integer Dim SearchFolders As Variant row = 3 LookInTheFolder = "I:projects2Koch58MY8900PROCESS2013 Work (Phase 3)DIH_SulfolaneEquipment"
I need some help, I know very little about macros but is it possible to create folders/directories to a certain path using the text in an excel spreadsheet cell? For example, if cell a2 has a street address and cell b2 has a city, can it automatically create a directory in the path of my choice using that data? If yes, can it go down the the rows and create directories until it is done?
Please help as I have hundreds of directories to create.
I'm trying to save a spreadsheet using VBA which will also check that the directory exists and create it if not, all based on cell values in my spreadsheet. When I run my code it comes up with Run Time Error 76: Path not found.
Dim fname As String, dname As String, dname2 As String fname = ActiveSheet.Range("E2").Value dname = ActiveSheet.Range("G2").Value dname2 = ActiveSheet.Range("H2").Value Windows("Register Template.xls").Activate ChDir ("H:") If Len(Dir(dname2, vbDirectory)) = 0 Then MkDir dname2 End If ChDir dname2 ActiveWorkbook.SaveAs Filename:=fname
I have attached a workbook that creates new folders based on text in a cell. As you can see when the button is pressed it runs the macro which when it is done calls the next & so on. What I would like to know is there a way of acheiving the same results with a single macro. Eg column A contains 4 cells with text. The macro when run will check for cell content then create folder based on that text macro will stop when next cell is empty.
Am trying to copy 50 worksheets from One workbook, into separate existing files (overwriting previous file) in existing folders; once copied, destination files can not be linked to source file.
I'm able to copy the tabs into new workbooks, in the correct folders, but when trying to perform PasteSpecial in new books, original source file is also pasted over.
The parts of the file name and folder location are cell values located on each sheet.
...
For Each sheet In ThisWorkbook.Worksheets sheet.Copy Set workbook = ActiveWorkbook With workbook.Sheets(1) .UsedRange.Copy .UsedRange.PasteSpecial xlPasteValues .Cells(1).Select Application.CutCopyMode = False End With
I understand that you can do dynamic named ranges for graphs, using one named range for each series and another for the categories. However, the graph I'm working on will have a lot of series'. Is there a way to do this cleverly? I'm trying to avoid making a named range for each one.
I need to create a series which must look like in third column. This can be done using concatenate and & function but what i need that 01 & 02... must get autogenerarted and i have to use only first two column as source.
I have a need to expand data rows such as the following example:
A cell in a column of alphanumeric characters contains for example: 9,2,36J,10-13,42L-42N In this example I need to replace this row with 10 new rows (deleting the orginal) so they would be expressed like this: 9 2 36J 10 11 12 13 42L 42M 42N
I would like to create a list of folder/directories in the current directory. The only code I've been able to find lists all files in the current directory (not folders).
way of returning a list of folders that contain a user defined search string in their name. Eg., return all the folders within a directory/directories that have "x365" in the name.
I am searching through a list of over 6000 folders that are sitting in four different directories.
The following is the code i've come up with so far that creates an array called aFoundList containing all the folders that match my search string.
Sub TryOpenFolder_LoopingMethod() Dim FSO As Scripting.FileSystemObject Dim oFolder As Scripting.Folder Dim vSubDir As Variant Dim vSearchDir As Variant
I have a folder that has a bunch of other folders in it, each containing many files. Is there an easy way to get a file directory into excel, so that I now would have a spreadsheet that tells me what all the folders are and what files are in each one?
short example: main folder = mystuff subfolder1 = my pix, contains pic1 and pic2 subfolder2 = otherstuff, contains otherstuff1 and otherstuff2
Can excel find these things and give me a list indicating that the 'mystuff' folder contains these two folders, and also list the two files under each folder?
I've tried several things to accomplish this with no luck, but I'm sure it's not too tough to do:
On my worksheet, I am entering columns of cells with alphanumeric data. The data are actually thousands of reference numbers that need to go in chronological order, with only the numerals changing (e.g., ABC0001DEF, ABC0002DEF, ABC0003DEF..., with "ABC" and "DEF" always the same).
I can create a series just fine if I leave off the "DEF" part of the reference numbers (by selecting the first couple cells in the series and using the fill handle), but I can't get the same results with the numerals "nested" within the reference numbers (i.e., ABC####DEF).
It sure would save me a lot of typing to be able to create a series to fill in all my reference numbers!
I'm now trying to get my chart to use that range. I read at [URL] .... that I need to make sure my series reference is a fully qualified reference. So I've entered that series reference using the name of the workbook followed by the range name (=2012-PIRS.xlsx!SAM_CLAR2DEL). I have two copies of my workbook (one as xlsm with VBA project, and one with xlsx without VBA) and I can't get Excel to accept the series value in either workbook.
ERROR MSG: The formula you typed contains an error. Try one of the following: - Make sure you've included all parentheses and required arguments. - To use a function, click Insert Function on the Formulas tab (in the Function Library group). - If you include a reference to another sheet or workbook, verify that the reference is correct. - If you are not trying to enter a formula, avoid.........
I am attempting to use a dynamic named range in a chart data series as described in Excel Hacks (Hack #42 and Hack #52).
Using Insert|Name|Define I have created a named range called CashFlowSaleChartDataRange that is set to the following value:
=OFFSET('Cash Flow-Sale'!$O$10,0,0,NumFlows,1)
When I subsequently assign a reference to this named range in the data series dialog it will accept the answer and my chart will adjust to reflect the updated range. However, if I return to the data series dialog, I now see the range address returned by the OFFSET function rather than the named range reference.
I am trying to assign a named range to a series on a preexisting chart in a sheet, but I get the error that "unable to set values property of series class". This is the code example that DOESN'T work:
Sub assign_values() Dim myrange As range Set myrange = range("a1") Set myrange = union(range("a5"),myrange) activechart.seriescollection(1).values = myrange End Sub
However, this code DOES work:
Sub assign_values() activechart.seriescollection(1).values = range("a1") End Sub
I don't see why the first wouldn't work, but the second would work. I suspect it is something to do with the union function. i am trying to go through a set of data and then group certain cells into a named range to be used on the graph.
I need to back up files, which may be excel or MSword, by copying them from different directories, say C: to the backup directory, say X:. any vba to backup the files? I expect the vba can copy all file listed in column A.
E.g. C: est1File1.xls or C: est2File2.doc, and then pasted to the directory in column B. e.g. X:BackupFolder1 or X:BackupFolder2.
I have the following procedure that creates sub folders for items in a named range (Room) in the parent folder (Pictures). The procedure works as expected; a sub folder is created for each item in the named range. What I'd like to do is give the User feedback as to what sub folders were created. This is the code I'm using:
way to create a group of folders in a specific location using a list of cells from an XLS file as the folder names.
For example, it would take whatever text is in Cell A1 and create a new folder in a specified location. It would take the text in Cell A2 and create a new folder in the same specified location. Etc.
I have a chart in a workbook that works fine by looking at the following data series:
=Workings!$A$2:$C$35
In the data series above...where the numbers are 2 and 35 I have named ranges "CHART_Start_Row" and "CHART_End_Row" which will change dynamically as appropriate and can replace these static numbers - but how do I incorporate these named ranges into the data series reference?
macro and I think this has me on my way; however, I do not understand the code and I am having difficulty modifying it. It returns the path in cell $A1 of my workbook, but I get reference errors in $B1:$L1.
I would like for the code to start entering the values in row 2 of my current worksheet. Row 1 I want to make a header row. The first column I like having the file path. Can the path be changed to a hyperlink? I would then like for it to return the values in $AP1:$BC1 to $B1:$O1 of my current workbook.
I am attempting to create a macro that will create a new folder on the network drive Arie:quotes that will create the new folder and save the the file in the new folder. I need the name of the file and folder to be set to the master (worksheet) cell "B3". and then if possible have it be conditional that if cell "B40" on the same master (worksheet) has a value to have the value added at the end of the filename via hyphen. This workbook has numerous worksheets in it approx 15 worksheets. I am not sure if this is relevant.
As an brief example.
Cell "B3" on the master(worksheet) contains a job name I-40 bridge So initially I would like the Folder name and file name to be I-40 Bridge
However once the Cell "B40" has been filled in with the value 54213 then I would like the file to renamed to I-40 Bridge-54213 and saved within the same folder.
I am currently working with Excel 2007 Pro edition on windows 8. I
I have found several other macro's that work with an auto save but i am unsure of how to change the directory to the network drive and show the correct file paths. This is the example of the macro I am currently working with.
Public Sub SaveAsA1() ThisFile = Range("B3").ValueMkDir "C:NewFolder"ChDir "C:NewFolder"ActiveWorkbook.SaveAs Filename:=ThisFileEnd Sub
I have managed to get this far - I have put together a macro (from different threads on this site) that opens closed workbooks, copies data in one of the sheets (same sheet in each of 28 books), and pastes the data it into a master book sheet, each paste starting below the last. So that bit is working. The first bit of help I need is a line of code that will make the macro loop through a number of sub folders in a main folder. My code at the moment works as long as I specify a path that ends with the name of one subfolder, and it only loops through this subfolder. I would like the path to end at the folder that holds all the subfolders ('Workbooks' in the path below), and then add some code that tells it to apply the macro to all subfolders in this folder, so it loops through them all.
The second issue is that after the macro goes to the closed book(s), copies the data in there and pastes it into the master sheet (into columns E:FG), I then need it to go back to the workbook it just copied from, go the same sheet, to three specific cells on that sheet (FH1:FH3), copy the content, go back to the master sheet, and now repeatedly paste the content (values only and transposed) of these three cells into three cells (in columns B:D, with row number being dependent on what rows the first lot of data was copied into) next to every row it just previously pasted in for me. When it loops to the next workbook, it needs to do the same, and the three cells will have different content than the ones in the previous workbook paste.
I dont know how to define the range it needs to paste into the second time. I tried using the definition I used for the first paste (MCDrow), to tell it that it is the same rows, just different columns, but this is not working.
Here is what I have so far, which does the first part of what I need, except for needing a way to have it loop through all subfolder in the 'Workbooks' folder (at the moment it lists Barwon South West as a subfolder in that path, but I actually have multiple subfolders, not all called Barwon South (all different names) that it needs to loop through and do both the first and the second paste for. I have taken out the code I was trying to use to do the second paste, as this was not working and the code is pretty messy as it is (I sort of bumble along, being so new, and I know the code is not very clean or efficient!).
Can someone help me put in the few lines I need to loop through all my subfolders (if you give me an example I can probably extrapolate), but to get you started, three of the subfolders are Barwon South West, Eastern Region and Gippsland. And can someone help me put in the code that will do the second paste for each workbook?
Sub Click2()
Application. ScreenUpdating = True Dim MCDrow As Long 'Dim SubFolders As String MCDrow = ThisWorkbook.Sheets("Client Data").Range("A65536").End(xlUp).Row
Fpath = "Q:Clinical ServicesCS Statewide DatabaseWorkbooksBarwon South West" ' change to your directory 'SubFolders = True Fname = Dir(Fpath & "*.xls") Do While Fname <> ""
I'm trying to create 3 different named ranges which are of alternate cells in columns. Each column runs from row 3 to row 106 and each named range covers 5 columns. Therefore each named range needs to contain 260 cells (52 cells per column x 5 columns).
Apart from the fact that you can't deselect a sell by Ctrl+Right Clicking on it, making a selection of the relevant cells is proving impossible.
For example I carefully selected all 260 cells for my 1st named range and entered a name. However when I then go into Name Manager I see that loads of cells haven't been selected at all and instead some cells in some columns have been but with huge gaps between them. If I try to then add cells my Ctrl+Clicking on them I find that I can add some but then one of two things will happen. I'll either click on one cell, the same cell every time, that deselects everything and I have to start all over again or when I try to save the new range I get a message saying the formula is wrong.
I've also tried typing in the names of the cells manually but the same thing happens. Annoyingly I've manually created a formula with all the cells I need in Notepad but even though the option to Paste is there, it won't let me paste into the field!
Is there a limit to the number of cells you can have in a named range?
Is there way of editing the name range accurately?
Is there a better, easier way of selecting all the cells for a named range?