Changing The File Paths In Macros

Jul 20, 2009

I am running the macro below which changes details in my spreadsheet using details from an external table.

Range("C7:E36").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=18
Range("C42:E51").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=18
Range("C58:E69").Select
Selection.ClearContents
ActiveWindow.SmallScroll Down:=15
Range("C75:E86").Select

If I want to perform this process without having to change the directory to the t drive etc, how do I change the macro? Is there a way, that as long as each of the relevant sheets are in the same directory, i can point the macro there? Ie, as long as all saved together in My Documents or Desktop, the macro automatically looks there?

View 9 Replies


ADVERTISEMENT

Managing Macros With Hard Coded File Paths

Oct 8, 2012

We have multiple macros that have been developed by various users in the company. Many of these macros have file paths hard coded into the macro to reference file locations with networked drives.

We are planning on making some changes to the network file structure which will break these macros. I realize we will have to go in and manually change all these. I want to ensure that the end users have the flexibility they want, but not have to touch each macro if/when folder structures change, or files migrate to SharePoint etc.

ini files, master reference Excel file...,

View 3 Replies View Related

Possible With Folder Paths And Macros

Mar 10, 2014

When I use the folder path on my computer it works great. However, Dropbox is in slightly different locations on other computers that would need to run the macro. Is there a way to get to the files without modifying the code for ever computer? The only difference in the folder path would be everything up to where Dropbox is in the path and would need to include usernames as below.

[Code] .....

View 5 Replies View Related

Dynamically Changing Csv File Or Macros

May 5, 2007

I am trying to find a way to dynamicly change CSV files .What I want is to add another column to the table with the values that based on the pre programmed parameters. For example if i have A,B,C,D columns and rows 1,2,3,4,5,6,7 I need macros to add values in column E based on the values of column B(for example)
I want to be able to pre-set those algorithms.For example for value 1033 in column B I need macros to insert value 1.25 in column E in the same row,for value 951 in column B I need 0.3 in column E in the same row. Is it doable just in Excel?

View 3 Replies View Related

Cell Values As File Paths

Feb 20, 2007

I have a file which I am using at work to compile production shift reports. I have created a sheet called Live Report and created a macro called 'New Day' that copies the entire sheet and renames it as yesterdays date (using a separate sheet called Data with a =today()-1 and text formulas thus the sheet tab for 14/2/07 is called 14 Feb) it then clears certain cells on the Live Report sheet so that information can be entered again.

My problem is that I want to now create a table of values that compiles values from each sheet for the month. What I wanted to do was have the names of all possible sheet tabs listed in column A and then as we get to each date the links will become active for the 20 or so values on each sheet. So each row will have the sheet tab name in column A and then columns B to R will have links to that sheet. As I am lazy and the linked values will always be in the same location I just wanted to drag the first row of links down the table using the value in Column A as part of the filepath/link.

My problem is no matter how much I try I can't use cell values in filepaths. If this is impossible I would like help with a macro that can find the right row in the table based on todays date and copy certain information.

View 9 Replies View Related

Opening File Paths Where Filename Will Vary

Feb 4, 2014

I'm trying to write code that will open files within a specific folder. However, the end of each filename is going to vary over time to the point that I'll never be able to predict the exact filename.

Is it possible to write something like:

Code:
Set wb = Workbooks.Open "C:\folderfile_filenumberxxxx.xlsx"

Where the "xxxx" signifies the variable element of the file name that could be any four characters? Failing that, is there a similar possible alternative?

View 1 Replies View Related

Pass Multiple File Names & Paths

Jul 16, 2007

How to write the VBA which can multi-select the files and store the selected filepaths in the string.

View 4 Replies View Related

Stop Working Out File Paths For Referenced Workbooks....?

Apr 29, 2009

I'm working on a sheet which references a sheet in another workbook. I want to refer to the other workbook simply by it's filename (Forecast.xls) but whenever I save and reopen Excel has replaced the filename with the full path (C:Documents and SettingskoconnorMy DocumentsAuto-sheet project[Forecast.xls])

This is quite inconvinient as I am eventually going to want to move both workbooks together to a different location. Is there a way to make Excel stop working out full file paths and just look for the filename in whichever folder the active sheet is sitting in?

View 3 Replies View Related

VBA Shell Command To A Launch Applications On All Computers (no File Paths)

Apr 14, 2006

The VBA shell command is as follows:

programPath = "C:Program FilesInternet Exploreriexplore.exe" ' works
'programPath = "iexplore.exe" ' does not work
Shell programPath + " " + fileToLaunch, vbNormalFocus

but the drawback is that the invoked program (iexplore.exe, at least in my case) needs to have the FULL PATH to where the program exists = the "C:Program FilesInternet Explorer" which may or may not work on someone elses computer. This hardcoding will not work and is not transportable.

Is there a trick to find where the executing program lives? or launching it without the path?

View 9 Replies View Related

Use Application.GetOpenFilename To Search For A Several (.jpg) Files And List The File Paths On A Worksheet

Feb 13, 2010

I am trying to use Application.GetOpenFilename to search for a several (.jpg) files and list the file paths on a worksheet.

View 2 Replies View Related

List Workbooks With Specific Sheets From ListBox Populated With File Paths

Nov 26, 2008

Split off from Fill Multi Select ListBox With File Paths & Open Selected Files

if I can add a other request I just thought of.

If a sheet is also in one of the workbooks list, can I add a link directly to it?
For example, Workbook1 has a sheet named "MARCH".

When i'm working on sheet "MARCH" I want to be able to click on a button to see the Userform I created from the script above and see if the sheet "MARCH" is present from the other workbooks listed, if there is a sheet "MARCH" in the workbooks listed, I want another listbox to show what files contain sheet "MARCH" and link to them.

View 9 Replies View Related

Fill Multi Select ListBox With File Paths & Open Selected Files

Nov 26, 2008

i'm having a problem with a script I have (script is below). What i'm doing is running a script that displays files in a certain folder, those files are then displayed on sheet1 column O and are linked so when they are clicked upon, the file will open. I also have a combo box with a input range of $O$O. That puts the values in column O in the combo box. Now here is a problem and request.

Problem first, when I select the file names from the combo box, they don't open the file, all it does is display the file name in combo box and that's it. how to I get it to open up the file? Now for a request, I have another sheet that is almost exactly as the one i described above. The only thing different I want is when someone clicks on a file name from the combo box, instead of it automatically linking to the file, I want them to click on a button to display the file.

Sub HyperlinkXLSFiles()
ActiveSheet.Unprotect
Dim lCount As Long
Application. ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
On Error Resume Next
With Application.FileSearch
.NewSearch
'Change path to suit
.LookIn = "c:Sec"
.FileType = msoFileTypeExcelWorkbooks
' .Filename = " Book*.xls"..................

View 2 Replies View Related

Using Cell References In File Paths For Formulas To Create Dynamic Formulas

Dec 3, 2013

I am using a lot of linked reports that have to be rewritten each month. For example smaller formulas look like this:

=('S:PUBLICProductionJob CardsMOLDING201311 November[440A SIDE SPOILER JOB CARD.xls]Production Parts'!B$228*2)+'S:PUBLICProductionJob CardsMOLDING201311 November[440A SIDE SPOILER JOB CARD.xls]Production Parts'!B$262+'S:PUBLICProductionJob CardsMOLDING201311 November[440A SIDE SPOILER JOB CARD.xls]Production Parts'!B$292

What I want to do is extract the file path from the above formula and make it a composite of several cell references.

So what I need is to have a cell where they can change the month and another where we can change the year. So I set up several named cells that look like this:

_MONTH =11 November
_YEAR =2013
_JOBCARD ='S:PUBLICProductionJob CardsMOLDING
_PATH =_JOBCARD & _YEAR &"" &_MONTH

I tried several versions, I am hoping for something like this:

=('_PATH &"[440A SIDE SPOILER JOB CARD.xls]"Production Parts'!B$228*2)+'_PATH &"[440A SIDE SPOILER JOB CARD.xls]"Production Parts'!B$262+'_PATH &"[440A SIDE SPOILER JOB CARD.xls]"Production Parts'!B$292

View 4 Replies View Related

Changing Picture Using Macros?

Jun 28, 2012

My objective is to change a picture in a cell depending on the previous cell for example

If the number at B1 is bigger than A1, a mouse(example only) must appear below. If B1

View 7 Replies View Related

Automatically Changing Copy Range In Macros

Mar 18, 2009

In my program I have data coming from an outside workbook. The amount of data coming into my program changes (Additional Rows) could be more or less. What I want is for the macro to recogize the change in data size and copy the new amount automatically. ie Change copy range. I would post the program but it is proprietary.

View 8 Replies View Related

Macros Assigned Shape - Colour Changing Code

Mar 13, 2014

I have made several Shapes and assigned macros to them, all is good.

What i am curious about: is it possible to highlight or change colour of the shape on press and return to normal if another is shape is pressed? Just anything to make that particular shape stand out that it has been selected then return to normal when another shape has been selected...

[Code] ....

That is the code so far that is attached to 1x shape...

View 5 Replies View Related

Link To External File With Changing File Name

Jun 12, 2007

Basically I want to point my Excel sheet to a bunch of external Excel files. To get data from an specific cell (in this case, cell F10) of the external file, all I have to do is this: ...

View 9 Replies View Related

Referencing File Name While Changing File Name

Jun 8, 2007

I have a more general question. When doing something such as loading a picture, is it possible to be able to have code which the loading file name changes with a variable. For example, if I have pictures with names 1.jpg thru 120.jpg(all in the same directory) is it possible to write a code that loops and loads the proper image without having to write a section of code for each file name? This would be the directory(C:Documents and Settings muzaDesktopNew DatabaseDatabase Images312312_250) so could I code the filename calls something like this with having picname be the variable which goes from 1 to 180:

.Pictures.Insert( _
"C:Documents and Settings muzaDesktopNew DatabaseDatabase Images312312_250" & picname & ".jpg").Select

View 2 Replies View Related

Changing Reference From Current Years File Data To Blank File Data

Feb 19, 2014

I have a blank file and a data file for current year with formulas.

So I am trying to take a couple of tabs from current year data file and pasting them into the blank file.

My question when is do that all the formulas get referenced to the current years file. i want to keep the same formulas but reference the tabs on blank file.

Is there a quicker way to do this rather and going into all the cells and changing reference from current years files data to blank files data.

View 3 Replies View Related

Keeping Macros With File.

Jan 5, 2010

When I copy/paste an Excel 2003 file containing macros into an email and send and open into another computer, the macros are gone. How can I ensure the macros go with the file?

View 8 Replies View Related

E-mailing A File In Macros

Aug 7, 2007

I have a couple of spreadsheets that I have to mail out monthly to the same recipients and I have figured out how to do that in the macro. However, an Outlook alert pops up warning me that an outside program is attempting to send a message and I have to approve the sending of it. I have tried using the Application.DisplayAlerts = False statement, but that apparently only suppresses the displaying of warnings and alerts in Excel, not the entire Office suite. Is there any way I can make this message go away and just send the e-mails w/o intervention?

Second, I have another spreadsheet which imports data from our UNIX system that I run twice a week. It analyzes, massages and reformats the data, then saves it to a text file, which then gets sent to the same recipients every time. Is there a way to send the text file as an attachment automatically through a VBA macro in Excel? If so, how? So far, I have been able to find help on how to send the entire workbook or a sheet within the workbook, but not a file other than the workbook.

View 9 Replies View Related

Put Together A Set Of Macros That Perform Certain Operations Within A File

Jun 22, 2009

I'm try to put together a set of macros that perform certain operations within a file. However I've got a bit stuck on the following, and I can't see where I've gone wrong:

View 3 Replies View Related

Reduce File Size By Use Of Macros

Jan 8, 2007

I still cant figure out how to write macros. If someone could help me out with this I would appreciate it.

Currently I have a worksheet that is 20mb.

This file contains what takes up most of the space. I repeat this line many times throughout the worksheet.
010807.zip

Once again it is a zero eliminating code.

If someone could reduce the number of formulas for me, I think I could figure out how to adapt it to repeat throughout the sheet.

View 11 Replies View Related

Remove Macros To Email File

Jun 17, 2009

I would like to email an Excel file without the macros so the end recipients will only see the data and not be confused or excited about the prompt to enable/disable macros.

View 2 Replies View Related

Delete Any Macros Which Exist In File With Vba

Oct 15, 2004

Is there anyway in which I can open a spreadsheet and then delete any macros which exist in that file with VBA?

For Example
Workbooks.Open "\sysdevwebwCorpAcctSuiteReportsNetProfit.xls"
''Delete Any Existing Macros Code''
Activeworkbook.Save
Activeworkbook.Close

View 9 Replies View Related

Macros - Changin File Name Results In Bug.

Sep 30, 2008

I have a couple of basic macros that edit formatting in a sheet that I want to send out to various people. The problem is, when I change the file name of the worksheet - the marcos stop working as they refer to the actual original file name.

Could someone please advise if (I am sure it must be somehow) it is possible to emmend the Macros in some way so that they continue to work regardlesss of what the end user decides to name the worksheet.

View 9 Replies View Related

Open File From A Macros To Get Some Data From It

Jul 9, 2009

1- how can i open an xls file from a macros to get some data from it?

2- how can i set a wait function, till i press a special button before macros will be able to continue.

e.g.:
[macros.xla]

View 9 Replies View Related

Moving 2003 File With Macros

Jul 24, 2009

I've created a spreadsheet that I need to share. I've created a custom menu with macros. When I copy the spreadsheet, the macros refer to the original file with an absolute path. Is it possible to copy the spreadsheet to another location and have the macros use that path?

View 9 Replies View Related

Temp File Not Saving Macros

Jan 20, 2010

The form is completed by the project leader, then they hit a Command Button and it's sent to the Senior Manager. After the Senior Manager looks at it and approves it, he then sends it on to Admin (me!) so the project can get set up on all of our systems.
We recently upgraded to Office 2007 (yes, we are a bit late!) and now the Macro that sends the form to Admin no longer works. An example of the error is as follows:
Cannot run the Macro "FY06-10 PROJECTS 19-Jan-10 08-32'EmailtoAdmin.EmailtoAdmin'. The macro may not be available in this workbook or all Macros may be disabled.

Here is the code that I use to send it to the Senior Manager:
Sub MailtoSM()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sourcewb = ActiveWorkbook
ActiveSheet.Copy
Set Destwb = ActiveWorkbook

With Destwb
If Val(Application.Version) < 12 Then

FileExtStr = ".xls": FileFormatNum = -4143
Else.........

View 9 Replies View Related

Unable To Open Multiple File And Run Macros In It

Dec 20, 2013

I am facing an issue where my macro is unable to open multiple files and run the macros in it. Below is the code that i am using and it stops at boss1.

VB:
Sub allboss()

Call boss1
Call boss2

End Sub

[Code] .....

View 2 Replies View Related







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