VBA Use Filepath In A Range To Put Into SaveAs Statement
Nov 24, 2012
I am trying to use cell C6 in my control sheet
Which is this
C:UsersNeilWin7DBTradingETFfiles
And put as a string into SaveAs
wbNew.SaveAs Filename:=Worksheets("Control Sheet").Range("C6") & TickerIndex & "ProSharesNAVRatio" & ".txt", FileFormat:=xlTextWindows
View 3 Replies
ADVERTISEMENT
Jun 20, 2013
I have defined part of a file path as a string variable so that I don't have to type in it everytime I need it. I then try and use this variable to open a workbook, but I get an error message saying:
Expected: list separator or )
I use the code:
Workbooks.Open(filepath1&"filename.xls")
where filepath1 is the string variable
Can't work out why it doesn't work...
View 3 Replies
View Related
Aug 7, 2013
Upon clicking a button in a userform, I would like a MsgBox to appear, allowing the user to browse their file directory.
Upon selecting a folder in the file directory, a new excel workbook is created with the filepath chosen and named based on a previous MsgBox (which ive already accomplished), and the filepath is recorded in a cell on Thisworkbook.
Is this possible and if so how?
View 1 Replies
View Related
Mar 21, 2014
I have a 4 cells which contain the followng information, To: Email address, Subject: Text, Body: Text, File Path: File path (as Hyperlink).
I need the file path cell to update automatically when the file is saved somewhere new. This filepath is then used in an email that is generated with code so that the person opening the email can click on the link and open the file.
What I cannot seem to do is to get the file path to be something that updates automatically (which is functionality that I must have)but that also remains as a hyperlink for when it goes in the email (I have an additional problem at the moment which is that the hyperlink does not seem to work in the email - it keeps saying file cannot be found. I don't know if this is something to do with our systems and the way I am referring to the file?!?)
The cell with the file path currently loks like this:-
Cell AX Cell AY
File path file:///E:PART_TIME_LEAVEPART_TIME_PS_LEAVE_RECORD_EMAIL_VERSION_STATUTORY.xlsm
View 11 Replies
View Related
Mar 18, 2008
In A1 I have C:SpreadsheetfolderSubfolderTestSpreadsheetA.xls as a string.
In A2, using VBA I want to extract the string C:SpreadsheetfolderSubfolderTest i.e. take A1 value and exclude the SpreadsheetA.xls.
View 9 Replies
View Related
Jul 11, 2008
i have a userform where a user is able to specify a filepath via textbox. I would like to find a way of determining whether or not the filepath which is given is a legitimate path...
how to determine through vba if a filepath string is legitimate?
View 9 Replies
View Related
Sep 4, 2006
Does anyone know the code for obtaining the filepath of the current workbook? Tried a search and can't find anything on this.
View 9 Replies
View Related
Jul 24, 2009
I need a macro to export a range of cells to .html. The Save as Web Page works fine for me except a few thing that I need to automate. The macro I use now looks like this (recorded):
View 3 Replies
View Related
Apr 20, 2012
I'm trying to 'find and replace' part of a filepath which is buried in hundreds of formula, but when I hit 'Replace All' a file navigation window appears. Hitting cancel simply bring up another window, and again and again, each time a replace is executed.
View 3 Replies
View Related
Apr 9, 2014
I am changing command buttons over to shapes for aesthetic purposes. I went to assign a macro to call useform4 using a rectangle with the following code:
[Code] .....
It throws me some kind of file path error which makes no sense. Do I have to dim the rectangle2 for active sheet or something?
View 11 Replies
View Related
Jun 6, 2014
display workbook not found in Array set without Filepath, As for workbooks found we can use Dir function, but it is not work for workbook not found. The Dir() will return Blank.
e.g. in my filepath only has Book1.xlsx.
[Code] ....
MsgBox CountFound = 1
MsgBox CountNotFound = 3
MsgBox FileFound = Book1.xlsx
MsgBox FileNotFound = Blank
View 4 Replies
View Related
Mar 14, 2014
I have the following code to do something similar to above but I need to add the filepath as a hyperlink to the email along with the body text. I have 4 cells in the Excel workbook that contain 1) Who to sen to:, 2)The Subject:, 3) A sentence for the Body of the email and 4) The filepath of the workbook as a hyperlink.
I want to add both the Body text and the hyperlink to the email so that the person opening the email can click on the link and open the file.
[Code] ....
View 10 Replies
View Related
Oct 23, 2013
I have written code that allows the user to open a file. To make things easier I changed the file path to point directly to the folder where all the needed files will be placed. The problem is everyone that will be using this work book map their drives differently. One user may have it as H, and the other as J. Also users can have the same drive mapped but at two different starting points. Ex: H:DataReportsxxxyyy or H:Reportsxxxxyyy this causes the code to crash. Is there a way do default the path so it will not matter how the drives are mapped?
Here is what I am using so far:
Dim filt As Variant ' flit to be used in the getopenfile. variant is need for its multiple
Dim FilterIndex As Integer
Dim Title As String
[Code]....
View 2 Replies
View Related
Feb 8, 2008
I'm trying to get Mac OS X Excel VBA to understand this code however the ChDir reference and the filepath seem to be causing problems. I would like to specify in the code where the file should be stored but I did try removing the filepath section altogether but to no avail.
Option Explicit
Sub SvMe()
'Saves filename as value of A1 plus the current date
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("A1").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = fName & " " & Format$(Date, "mm-dd-yyyy")
' Change directory to suit your PC, including USER NAME
ChDir _
"C:Documents and Settings USER NAME Desktop"
ActiveWorkbook. SaveAs Filename:=newFile
End Sub
View 2 Replies
View Related
Jan 13, 2007
This is hard for me to articulate, so hopefully someone will understand what I'm trying to do.
I'm attempting to construct a formula in Excel, that basically says: IF the value is between these two numbers, multiple them by this percentage, or if the value is between these numbers, multiple it by this percentage.
So, let's say cell A3 equals 10,000,000, A2 equals 5,000,000 and A1 equals 1,000,000... Also cell B3 equals 10% and B2 equals 5%. We'll say that number X is in cell C1. If the number X is between 10,000,000 & 5,000,000 it should by multiplied by 10%. If number X is between 5,000,000 and 1,000,000 it should be multiplied by 5%.
I've tried a formula similar to: IF(C1 (Rng(A3:A2), C1*B3) ---- Meaning that if the number is between 10,000,000 and 5,000,000, multiple the number by 10%.
View 12 Replies
View Related
Apr 9, 2009
Is there a way too get the SaveAs box come up with a marco? When you go too file and save, a box comes up and lets you choose where and what you save. I would like too have it come up with a command button if its possible.
View 3 Replies
View Related
Dec 31, 2007
Sub CrearCSV()
Application.DisplayAlerts = False
ActiveWorkbook.Sheets("Prueba").Activate
ActiveSheet.SaveAs Filename:= _
ThisWorkbook.Path & "Prueba.csv", _
FileFormat:=xlCSVWindows, CreateBackup:=False
Set CSVfile = ActiveWorkbook
CSVfile.Close savechanges:=1
End Sub
Sheet "Prueba" is Hidden
Other Sheet is visible
Why SaveAs stores only the visible Sheet?
How does stored hidden Sheets with WorkSheet.SaveAs?
View 9 Replies
View Related
Apr 29, 2009
I'm running a macro in a template and trying to save the results to a different folder.
I want the file name to be blank in the Saveas Text box of the UI also. Unfortunatley my code is bugging out & I can't work out why.
ActiveWorkbook.SaveAs Filename:="C:", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
The save to path does change so I want to be able to change the save location.
View 9 Replies
View Related
Jan 14, 2010
It is supposed to bring up an input box, the date entered in input box becomes the date of file. The file is then Saved As. This all seems to work but when I try to open the newly saved file the sheet does not open. Is this a file type issue? Should it be .xls?
Code so Far
Dim InputDate As Variant
Dim FileType As String
Dim myFileName As String
Dim myFolder As String
FileType = ".xls"
myFileName = "Report"
myFolder = "Q:Sales FinanceAndyDUBLIN MACRO TEST"
View 9 Replies
View Related
Aug 8, 2013
I am trying to loop through a range, checking for a cell to contain one of two characters and then put a value in a cell to the side (well 3 away) of it. Im getting an error for Type mismatch on line:
VB:
If CellContent = "h" Or "v" Then
the data in the cell is an along the lines of '12.34.56.43 som-thi-vh-ng1'
VB:
Dim MyRange, MyCell As Range
Dim CellContent As String
Sheets("Sheet1").Activate
[Code]....
View 1 Replies
View Related
Jul 23, 2009
I am trying to do a calculation based on the conditions of two cells but one cell I would need the range of the report. Either way, here is my current statement.
=IF(P2:P15 = "Green Building 15",SUM(COUNTIF(C2:C15,"Over AC")+COUNTIF(C2:C15,"Top Lab AC")),0)
I get a Value# error (though it systematicaly works if you check in the funtion area), and its because of the range I am using, is there anyway to bypass thiss issue or can someone give a better calculation.
View 4 Replies
View Related
Aug 28, 2009
I have tried over and over to get a point value from the percentages posted below but my formula will not return consistent results. Am I doing something wrong.
94% - below 1 Point
95%-96% 2 Points
97% 3 points
98%-99% 4 Points
0% or 100% 5 Points
Reference Cell is AG2 and is .99 but for some reason I return a 5
=IF(AG2=0,5,IF(AND(AG2>0,AG2<=0.94),1,IF(AND(AG2>=0.95,AG2<=0.96),2,IF(AG2=0.97,3,IF(AND(AG2>=0.98,A G2<=0.99),4,5)))))
View 6 Replies
View Related
Apr 7, 2009
I dont know how to nest and if (if that is the right way to go about it). this is what I have ....
View 10 Replies
View Related
May 2, 2012
Need all numbers in between the ranges set. So if I input for example 8765 then the cell still comes up with 18.
IF Cell E25 is 0-7200, then 12, If cell E25 is 7201-14400,
then 18, if cell E25 is 14401 - 21600, then 22,
if cell E25 is 21601-28800, then 28, if cell E25 is 28801 - 36000, then 34.
View 4 Replies
View Related
Jun 21, 2012
so on sheet 1 i have a list in column b (as below) and in column G I want to put a note "not included" if the cell matches what is in sheet 2:
AAA
BBB
CCC
DDD
EEE
On sheet 2, column A I have a list of items that I want to not include which I want to be able to add/remove/adjust over time. For example:
DDD
EEE
FFF
LLL
I can get it to put in the correct text into sheet 1 with the following but I don't know how to get it to look through all values on sheet 2 and then only enter the "not included" on sheet 1 if it is listed on sheet 2.
So far I have
Sub checksheet()
For Row = 1 To 428
For col = 2 To 256
[Code]....
This only does it for what is written in cell A3 on sheet 2 and does not keep going down the list in sheet 2.
I think I need to define the range better on sheet 2 and ask it to look through that, but im not too sure.
View 4 Replies
View Related
Aug 9, 2007
I was making a simple spreadsheet as I'm taking practice tests for some IT certifications and the spreadsheet I was making was to chart out my progress.
I had a range of scores in some cells and one of the formulas I used so that I didnt have errors in the sheet like div/0 went like the following:
=if(b5:b50="","",sum(b5:b50)) this seemed to work really well for the one section, however I tried to get a little fancy as always and I think I messed something up. Beneath that I tried to separate each practice test with the same sort of formula resulting something like the following:
=if(b30:b40="","",sum(b30:b40)) this however just returned an error #value. I dont understand why the first formula worked and the second didnt. Then again, I'm not really an excel guru, back in college I was really good with it but I dont really remember much.
View 9 Replies
View Related
Aug 10, 2007
I'm trying to create an if statement that have 2 criterias. Here's what I've created:
=IF(COUNT(F2:F4)=('2007Open'!H2:H4),COUNT('2007Open'!B2:B4)=8,'2007Open'!H2:H4)
This statement is returning the #VALUE error.
I guess what I'm trying to do with this statement is to count how many values are not equal to 2007Open!H2:H4 and meets another criteria of 8.
View 9 Replies
View Related
May 19, 2009
I'm trying to create an IF formula that returns the month as text between a certain date range in a different column.
For example
Between the 25-APR-09 and 23-MAY-09 I want to display "May" 24-MAY-09 and 27-JUNE-09 "June"
And so on so forth, the column with the dates in it is in date format.
View 9 Replies
View Related
Mar 21, 2007
I need a formula that will return "true" only if ALL cells in the specified range are not Null (<>""). I'd like to assign a value (% complete) only after all tasks under a phase have been given a completion date.
View 7 Replies
View Related
Aug 6, 2005
An already existing file will be changed by my macro and at the end I want the user to save the file with a different name in a different directory with the option to change the filename or directory. Therefore I use the excel-standard-dialog "save as". But I want the dialog to start in another path as the path the original-file is stored in. But also I use the ChDrive and ChDir Parameters the dialog even starts in the original-file-path. I think this is standard for the dialog and I should maybe use a parameter in the show-arguement? The code is below.
Option Explicit
Sub SaveMyFile()
Dim xFileName, xAnswer
ChDrive "J"
ChDir "J:myfolder"
xFileName = "testme.xls"
xAnswer = Application.Dialogs(xlDialogSaveAs).Show(xFileName)
End Sub
View 5 Replies
View Related