Code To Create Directories From Cell Values

Feb 26, 2009

I have a CSV file and would like to create directories on my hard drive and the names of those directories will need to be pulled out from this csv file: [B1:B86].

For example I have the following data in my csv file:

B1: folder1
B2: folder2
.
.
.

And would like to create folders on my hard drive so that folder names will be: folder1, folder2, ...

View 9 Replies


ADVERTISEMENT

Create Sub Directories From Cell Values

Oct 7, 2007

Create sub directories from Cell Values

I Need a VB macro to Create sub directories unless sub directory already exist. My file will be Save 5 Level deep. Each Sub Directory will be cell value in a Worksheet .
Example C:CategoryYearSeriesMonthBimonthlyFile Name.xls

I will be using this in over 100 different files so I want to be Generic as possible

View 6 Replies View Related

VBA Code To Create A Paste Special Values Keyboard Shortcut

Mar 20, 2009

I have written a short VBA code to create a Paste Special values keyboard shortcut.

Is there a way or a place that I can put this code so that every time I open any workbook in Excel, or open Excel itself that this VBA code will be active and I can use the keyboard shortcut?

View 3 Replies View Related

Create Macro Code That Auto Fill Cell With Formula?

May 23, 2014

When I enter data in the cells A1 and B1, C1 needs to calculate the result. (not copy and paste)

For examle: I have formula C1=(A1+B1)/2

C column for formula, but shows result only when there is a data in A and B

View 7 Replies View Related

Create Button In Excel With Macros Or VBA Code In A Specific Cell Targets?

Jul 9, 2014

I have created a individual tracker spread sheet in each user system and on the spread sheet I have inserted 2 buttons in 1st sheet. when employee wants to take a break he has to click on the log out button and when he came back he needs to click on login button. I have another sheet named "timings" and I have created 2 columns, one is login and another is logout. What I need is when user click on the login button, the system time and date to be auto update under login column and when he clicks on logout button the system time and date to be auto update under logout column.

View 14 Replies View Related

Create New Tabs From Values In A Cell

Feb 10, 2014

I have a large spreadsheet and want to sort by Column "L" and copy all the rows where Column L has the same value into a new tab named with the value in Column L.

View 2 Replies View Related

Excel 2013 :: Create New Values Based On Number In One Cell?

Jul 21, 2014

I have the following data set with about 500 rows. It has one large value in column A, followed by a number between 1 and 24 in column B.

I am trying in Excel 2013 to develop a formula that will: divide A by the value in cell BPlace in cell C, D, E, F... the result of this division, where the number of times the value is repeated depends on the value in B. E.g.

Example of source values/data set:
A
B

18504
18

2011
2

23694
24

(about 500 rows more)

An example of the output result that I am looking for:
A
B
C
D
E

2011
2
1,005.5
1,005.5

In above example, the value in column B is 2, so the result of the division of value A with value B is repeated twice. In case value B would be 18, the value would be repeated 18 times...

I have been trying to do this in Excel for more than 2 hours, but I did not manage to complete it.

View 2 Replies View Related

Create Documents Based On Cell Values And Input Tabs In New Document

Sep 12, 2013

I want to create a macro that creates a new .xlsx document based on cell values. And input 4 tabs into each document with specified tab names. I have a document that pulls from external sources and fluctuates with amount of data per day. I envision something that will make a new document named for the contents in cell A1, then function as a control+down to create a new document for A2, then A3 until there is no content left (should mention these are lookup formulas, and if there is no data it pulls a value of "0")

Is there a way to put in the code, the tab names it would create in each new document, or would that have to look to a cell value for the naming? The tab names would be "GS", "MYSS", "COLL SHEET", and "WIRE".

View 1 Replies View Related

Can Automatically Create Named Ranges Based On Adjacent Cell Values?

Jul 11, 2013

Macro that could look at a row and take the values of two cells, combine them and then create a range name for a third cell in the row.

For example; for row 5420, in column C there is the word Florida, in column D there is the number 6235, and in column F there is a sentence or two. Is there a way to automatically create a named range for the cell of column F that would be named FLORIDA6235? And if so, can the macro do this for every row even if the word and/or the number changes.

I have roughly 28,000 rows and nine columns that I am working with. That's why I was wondering if there was a way to automate this. There are 10 states and I don't know how many different numbers attached to the states, however there are many state and number combinations that repeat, so there would be several rows with Florida in column C, 6235 in column D but a different description in column F.

View 9 Replies View Related

Make Directories Using VBA

Feb 5, 2010

I need to use VBA to test if a certain directory exists and if not ten create it.

I do this with:
[CODE]Sub MakeDir()
Dim DirName As String
Dim FileName As String
Dim fnameshort As String

FileName = "C:TestA1ATest.xls"
fnameshort = Right(FileName, Len(FileName) - InStrRev(FileName, ""))
DirName = Left(FileName, Len(FileName) - (Len(FileName) - InStrRev(FileName, "")))

If Dir(DirName) = "" Then
MsgBox "Does not exist"
'Dir to be created using MkDIr
End if
End Sub/CODE]

My problem is that I need the script to loop back until it finds a folder that exists, and then make the respective subfolders.

Example:
C:TestA1A should be created, but currently only C:TestA exists.

VBA should then test for the full path, and when it finds out, that it does not exist, it should strip off one folder, test for that and so forth.

When it finds an existing folder, it should then make the respective subfolder, and then the subfolder to that...

View 9 Replies View Related

Move Files Into Directories Using VBA?

Mar 2, 2009

In my Excel file, I have three columns: A, B and C. Column A holds the folder names. column B holds the files hash names. And in column C, i keep the files real names, i.e:

A1.value = Contract folder

B1.value = 23ffryu567894lkgj090

C1.value = picture1.jpeg

On my hard drive, I have all the folders (column A data) already created inside a folder called directories: E:directories... There is another directory on my drive in which I keep all the hash files: E:infiles

And all I would like to do now, is to write a piece of code to read all three columns row by row and based on the data in that row, moves the hashed file into their proper directories and rename them to their real name. In the example above, the program should read the data found in the first row: A1, B1 and C1 and move the hash file named 23ffryu567894lkgj090 to E:directoriesContract folder and rename the hash file to picture1.jpeg

View 14 Replies View Related

Add Folders To All Directories Within Another Directory?

Nov 29, 2012

I am trying to automate some of the work I used to do as I have moved to another position, specifically trying to automate file management. I am using this code to create new files for each client

Code:
Public Sub CheckDir(fold1 As String)
If Dir(fold1, vbDirectory) = "" Then
MkDir fold1
Else
End If
End Sub

which works great, but you still have to do one client at a time. Basically I'm using this code to create new client files, but each year we will need to add a directory and sub directories for every client in a certain directory. What I would like to do is code a macro that would add say a "2013" folder with all appropriate sub directories to every client folder within the folder that contains all of the client folders The folder hierarchy should look like this

Code:
'F:Clients
'F:ClientsClientName
'F:ClientsClientName2013
'F:ClientsClientName2013RandomOtherFolders

I assume it would use a For/Each, but I'm not sure how to go about it.

View 3 Replies View Related

Change Names Of Directories

Nov 8, 2007

I have a folder structure like ex this c:my folders. Under this folder i have several folders and subfolders. I would like to use a macro to run through all this folders an sub folders and change the name of the first letters of all folders.

Ex
LOP-100-APPL
LOP-200-ORG

I would like to change LOP to PLP instead. I'm lazy and looking for a method for not doing this job manually. This should be done from the excel workbook.

View 3 Replies View Related

Macro/vba Get The List Of Directories

Sep 19, 2008

I am trying to access and copy some data from the excel file which is located in different folder each time I run the new macro. The file got the same name but only the folder name is different each time.

e.g File is called "testfile", but I have a list of subfolders something like that
date_time (folder name)
15-02-2008_2122 (folder name)
15-03-2008_2189 (folder name)

Each of the above subfolders contain "testfile" with new data and they all are located in the same drive and same mainfolder. Note my Macro file is located in a different drive.

I want when I run the macro all I have to do is to enter Date and macro will automatically pick up the right folder and the right file ("testfile") inside that folder and do all the required task.

View 9 Replies View Related

List Folders & Directories

Aug 22, 2006

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

View 3 Replies View Related

Relative Path With Different Directories - Especially Up One Level

Jan 4, 2011

Is there any way to reference a directory that is up one level from the ActiveWorkbook.Path?

I am trying to accomplish three goals:

1. Maintain a Master Database in a root directory and pull data from a subdirectory - EASY:

VB : FilePath = ActiveWorkbook.Path & "sub-DirectoryName"

2. Maintain a Minor Database located in a sub-Directory, Named by Month, and pull data from the Master Database located in the Root Directory (up one level). Which I cannot find the right syntax for - ".." does not work.

3. Maintain a Minor Database in a sub-Directory, Named by Month, and pull data from a different Minor Database in a Different sub-Directory (e.g. up one level to root directory, then down one level to "January"). Which I also cannot find the right syntax for.

The Databases are going to be moved around A LOT, so I have to use relative paths.

View 4 Replies View Related

Sort Files Into Desired Directories

Feb 13, 2010

search an entire drive from the root directory and down into all subfolders and copy all files matching various file types below to another drive into organized folders named for the file type. (for an example any .xls files in F: copy to G:xls .xls files) and also create an index in one excel file showing all the files in alphabetic order with its original path.

bmp
txt
xls

View 14 Replies View Related

Loop Through Directories & Files With Dir Function

Jan 18, 2008

I am trying to do is loop through a series of directories under a target directory. When a directory is found, it looks within that directory and finds any .xls files, loops through those and copies/pastes them to the new target directory. I have managed to get it to work only on the first iteration of the loop through the directories, then it crashes. The error code is "Invalid Procedure Call or Argument." Here's the

If valFilePath = True Then
MsgBox (msg)
Else
'Search for directories within source directory
strDir = Dir(ebsSource & "", vbDirectory)
'If a file has been found
Do While strDir <> ""
If strDir <> "." And strDir <> ".." Then
strFile = Dir(ebsSource & "" & strDir & "" & "*.xls")
Do While strFile <> ""
'Copy .xls files and paste in destination
copySource = ebsSource & "" & strDir & "" & strFile
copyDestination = ebsDestination & "" & strDir & "" & strFile
FileCopy copySource, copyDestination
strFile = Dir
Loop
End If
'Crashes here after looping through the first iteration of Excel files
strDir = Dir
Loop

View 2 Replies View Related

List Files & Directories In Worksheet

Mar 20, 2008

I found this nifty program on[url]but there is a problem with it and it's down to the types of files I'm trying to list on my PC.

The excel code below lets you select a starting directory and it will then produce a list of files in a sheet. However when it comes across an internet shortcut file it gets rather confused and won't display the name of the shortcut but what the shortcut stands for. This causes an issue when I try and get some details about the file (eg date, size etc.) as a 'permission denied' error can then occur if it links to a file that is currently in use. For some reason I can't attach an example of a shortcut / internet shortcut so please feel free to make one at your end. eg. I have a shortcut called 'ImageJ' which links to a web address [url]. The code below then reports this address instead of the file name 'ImageJ'. Can any one suggest how to amend this coding to handle this issue?

Option Explicit
'Requires a reference to:
' Microsoft Shell Controls and Automation (shell32.dll)

'Uses techniques found here:
[url]

Public objShell As IShellDispatch4

Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

View 5 Replies View Related

VBA Code To Find A Value - Cut And Paste Values Into Different Cell

Sep 27, 2012

I am looking to create some vba code that looks for a specific value in column 'm' (Z-AUD) for example and where it occurs within my data range copies and pastes the values in columns O,P and Q in to columns K,L and M.

View 2 Replies View Related

Save Work Book In 2 Separate Directories

Apr 5, 2007

I have a fluid document that I have to save for historical reasons in 2 separate directories. My save Macro works I was just wondering if anyone see's a better way of accomplishing saving to two separate directories then closing the document. I used the record function to gernerate most of the code.

Sub SAVEANDEXITTHESLATE()
Dim date1
Dim date2
Dim xlCalc As XlCalculation
xlCalc = Application.Calculation
Application.Calculation = xlCalculationManual
On Error Goto CalcBack
Application.ScreenUpdating = False
date1 = Now()
date2 = Format(date1, "mmm d yyyy hh mm")
ActiveWorkbook.SAVE
Application.DisplayAlerts = False
ChDir "c:Documents and SettingsmeDesktop"
ActiveWorkbook.SaveAs Filename:= _...................

View 5 Replies View Related

Code Errors On Setting Cell Values To A Formula?

Jul 15, 2014

the following two statements return the error "Application-defined or object-defined error"

Code:
Sheets("Purchase").Range("PurchaseTax").FormulaR1C1 = "=IF(RC[-1]0,ROUND(RC[-1]/11,2),"")"
Sheets("Purchase").Range("FreightTax").Formula = "=IF(FreightCharge0,ROUND(FreightCharge/11,2),"")"

View 2 Replies View Related

Locating Data From Closed Worksheets In Multiple Directories

Jan 28, 2010

I would like to create a macro which finds data from multiple worksheets and collates them in my Master Worksheet.

I am competent with a lot of functions with Excel, however I have never used Macro's before. I have a little bit of VB knowledge, but only the very basics. I will attempt to explain my situation as clearly as I can.

Please note in your response that I am not familiar with a lot of the programming jargon. I also do not know how to actually create (or is it record?) a macro.

Finally, before I dive into it, I would *prefer* not to have to add code to the closed worksheets, but I can do this if there is no other way!.......

View 14 Replies View Related

How To Populate Combobox With List Of Directories On Hard Drive

Aug 17, 2012

Is there an easy way to populate a combobox with a list of directories on the hard drive?

I want to create a way for a user to specify a file without having to type in the full address by hand.

I would like to start in the c:/ root and list the directories in one combobox and the excel files in another combobox. Then if they select say "desktop" it displayes the directories in "c:/desktop" and the excel files contained there in. Then if they click test it does directories in "c:/desktop/test" and so on.

View 2 Replies View Related

Combine Data From Specific Worksheets And Multiple Workbooks In Various Directories?

Feb 22, 2014

I have a master workbook that has been set up to mirror the structure of a single worksheet in various other workbooks saved in different directory locations. I need some VBA code to retreive specific data from a specified worksheet in multiple workbooks which are saved in different directories and then copy the data to the master workbook, listing each data set one after another. I do not want to open any of the source workbooks to acheive this.

I attach two example workbooks to better explain:

The code has to look in various sub directories to find the relevant workbooks, (Source1) then find the specified worksheet, (Stock) and copy only rows that have data from column B to O. The data needs to be copied to the master workbook, (master) from all the source workbooks as a list with no space.

View 4 Replies View Related

Create Macro Code With VBA Code

Feb 22, 2008

I'm trying to add buttons to an excel spreadsheet at runtime. Each row in the spreadsheet should have its own buttons. I was able to create and edit them with the ActiveSheet. OLEObjects.Add() function, but after that, when i was trying to create code dynamically to react on the buttons' click events excel crashes (actually it works for one button, but not if my routine for adding a new button and event code is called more than once in a row!)

The code below works if the AddCmdbuttonWithCode() is called once, but crashes if it is called two or more times. Excel tries to restore the document after the crash and the first button and its corresponding click event code is visible and works... but NOT the second button and its event code...

The only way I can create multiple buttons right now is by calling my method once per click, opening the vba editor, changing the parameters for my AddCmdbuttonWithCode() routine and execute it again. After that I have mutliple buttons in different lines which all work fine (so the concept seems to work).

The problem seems to be the insertLine method, since everything seems to work if i leave it out (except for the code generation of course, since this is done by this part of the code :-) ). Is it possible that calling the insertLine Method can't be called multiple times? I don't know... any ideas? Feel free to test my code - it's small, easy to understand and has comments.

'this code calls the method which creates the buttons in specific cells with specific names
Private Sub CommandButton3_Click()
'the first call always works!
AddCmdbuttonWithCode "Edit_111_111_114", 23

'the second one crashes excel
AddCmdbuttonWithCode "Edit_111_111_115", 27
End Sub

View 3 Replies View Related

How To Add 3 Horizontal Monthly Values And Create Quarterly Values

Oct 24, 2013

I have a data series running horizontally, which gives me monthly values e.g.

Jan 10 - Feb 12 - Mar 11 etc. Imagine the months are in row 2 beginning from column 2, and the values are in column 3.

I would like a formula which adds the three values, and in row 6 column two gives me the total for the quarter (10 + 12 + 11) and displays 33.

The next quarter value, I would like in row 6 column 3, etc.

View 5 Replies View Related

Passing Variables And Values Between Sheet Code And Module Code

May 13, 2009

I have some buttons in different sheets in an excel file, each button has its own code, that is the reason I can not move the code related to each object to another location (sheet or module).

And I have one piece of code in Module1 (Auto_load) in order to execute automatically this routine every time file is opened. Inside "auto_load" routine I initialize some values of some check buttons,options buttons and positions of some objects in diferent sheets, but I can not pass the value of variables between Module and Sheet's code even when I declare as public variables and/or function.

I have the following structure: ...

View 11 Replies View Related

Using VBA To Create VBA Code On The Fly

May 17, 2006

I have a vba module that reads a value from a txt file and saves that value in a variable called "iniInfo". I want to permanently assign that value programatically by using VBA code to create a Public variable e.g. "PUBLIC CONST conFIg = iniInfo" in my modGlobalVar Module. (Of course, this would only create the code if the "conFig" variable doesn't already exist.)

View 2 Replies View Related

Fill Values And Replace Told Values By Vba Code Depends Upon 2 Columns

Mar 26, 2014

I have set of data in multiple range ,need to fill the and replace the old values depends upon two column values (AH & AL)

IF Active Calls is "TATA" In AH:AH, and IF Action Onwer Col is "Blank",in AL:AL
Then Fill the Blank cells by Values "SVC" in the col Action Owner,Then Replace Old values by "Updates Awaited" in Status Col(AM:AM)

Find the attachment & basic code take this code for this task

[Code] ....

toggle-2.xlsb‎

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved