Searching For File Type And Copying Row
Jul 14, 2009
I have been asked to fix a macro that is supposed to search column B and find any cells ending with .mov. Any row fitting the criteria is to be copied to Sheet2. The file is a internet traffic log and we are trying to determine the number of downloads we have on our video files, which are all .mov format. Sheet1 can exceed 3000 rows.
Here's what I have so far:
View 2 Replies
ADVERTISEMENT
Jul 23, 2013
I have a spreadsheet that has a bunch of codes, I want to search all at once in another spreadsheet. If there there I want to copy the data related to that line into my spreadsheet.
Example:
I want to search a long list of items (in column D) in my “work in progress spreadsheet” The program would look into the “Data base spreadsheet” find the “item to search” in the database spreadsheet and copy the “product code” relative to those items, and populate column C with the product codes.
My work in progress spreadsheet
Col C ________________Col D
product codes ________Items to search
....................................G28
....................................G26
....................................F46
....................................J34
Database spreadsheet
Col C __________________Col E
Product codes __________items to search
Product code 16345210 ........J34
Product code 14454685 ........G26
Product code 14587541 ........G28
Product code 15754546 ........F46
View 1 Replies
View Related
Jan 18, 2007
I have a sheet named "original" with columns a, b, c. My code checks each cell in column C for a value and then copys columns A,B,C to a sheet named "Order". It works fine except I need it to start pasting the results in row 16 instead of row
Sub PLACEORDER()
Dim lastrow_first As Long
Dim lastrow_second As Long
Dim x As Long
lastrow_first = Sheets("ORIGINAL").Cells(Rows.Count, "C").End(xlUp).Row
For x = 10 To lastrow_first
If Sheets("ORIGINAL").Cells(x, 3) <> "" Or Not IsEmpty(Sheets("ORIGINAL").Cells(x, 3)) Then................
View 2 Replies
View Related
Jun 25, 2009
I need to search column C for the text "X". If an "X" is found, I need to copy the text from the cell directly left of it and paste it into a seperate worksheet into cell B2, then go back to the original worksheet and delete the cell with "X" on it and the cell to the left.
View 9 Replies
View Related
Aug 22, 2013
So I have the code that allows me to search for the a certain value in a cell and then copies a certain cell to the other spread sheets. Here is the code that does that
Code:
Sub SearchMacro()
Dim LR As Long, i As Long
With Sheets("Sheet1")
[Code].....
The code will just need to search for the string "HSFL" and I won't have to hard code all the different variations of HSFL as I mentioned above.
View 9 Replies
View Related
Jul 6, 2012
I am trying to open a website, then for excel to download the csv file, then for it to save it in a specific folder under a specific name and file format (excel).
I am successful at opening the website with the following code, but how to do the rest.
Sub Searchez()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://quote.morningstar.ca/Quicktakes/stock/keyratios.aspx?t=clwr®ion=USA&culture=en-CA&ops=clear" 'load web page google.com
IE.Visible = True
While IE.Busy
DoEvents
Wend
'IE.Navigate2 "javascript:SRT_keystuts.exportcsv()"
'this is the name of the download link as from when i hover my pointer over download link.
End Sub
View 1 Replies
View Related
Oct 22, 2013
I have a macro-enabled template file in Excel 2007. I would like the user to be unable to save in any format other than macro-enabled. They should be free to choose a path and filename, but not the file type.
I presume this means some VBA code in the before save event, but I don't know what.
View 2 Replies
View Related
May 16, 2014
Using Excel 2010
As I am looping through files in a folder, I would like to determine if the file is a text file.
The problem is that all extensions are variable in a pattern such as .078, .051, etc.
In this instance, the extensions are numeric, but I'm trying to figure out a way to handle that is all encompassing to include *.txt, *.tsv, *.csv, *.prn, etc......
How can I handle these efficiently?
View 6 Replies
View Related
Jun 15, 2007
The Code below searches for a file and displays how many files by that name it found.
Sub Test()
With Application.FileSearch
.NewSearch
.LookIn = "C:"
.SearchSubFolders = True
.Filename = "Temp.txt"
If .Execute > 0 Then
MsgBox ("Success: " & .FoundFiles.Count)
Else
MsgBox ("Fail")
End If
End With
End Sub
However, Flashdrives are a common use among those that will use the code, such that I need the code to not only search the hard drive C: but all hard drives and flash drives. Using .Lookin = My Computer did not find the files stored on my Flash Drive.
It finds it using .Lookin = "K:" but I can not rely on my flash drive always being K:. It does not find it using .Lookin = "PumaFlash" (Name of flash drive)
I'm looking for one of two things: Code that will Search all hard drives and flash drives (optical drives can be included) at once Code that will Find path for all hard drives and Flash drives and then search them separately
View 2 Replies
View Related
Nov 26, 2008
I have a number of project files that are maintained on the network.
These files are named "XXXXXX Project Name.XLS".
XXXXXX is the project number. This numbers are unique, so there is only one file per number within the directory. Project names are mostly unique, but sometimes they could be same for a specific site.
We recieve financial data in excel file format from home office. These reports reference only the project numbers, not the name.
I have created an excel program that extracts project numbers and related financial data from the report [from home office].
I would like to create a button or check box next to each project number in my program and link it to the respective file on our network. Once I access the local file on the network I could copy the financial data in its right place.
The problem is opening the file based on project number only, while the file names contain Project Name as well.
So, can I look up a file by only searching for first six characters of the name?
Or can the Hyperlink function work with some sort of wildcard? I can write the formulas to create the hyperlink and then write a macro to look for that file, but I need to be able to find and open the file by looking up only the first six characters.
View 9 Replies
View Related
Dec 11, 2013
The sub i'm currently using does an instr search for a unique string in an xml file. This works fine but i'd like to speed up the search if possible because I have a large number of xml files to search. My problem is that i have very little experience in parsing xml.
I notice that if i load the xml file and look at the namespaces i see item(1) through about item(20) and the unique string is always contained in one of those items. Note that the number of items can be different for each xml file i load.
The xml file is loaded into an object i define as oInstance and i'd like to do something like:
Do
counter = counter+1
if oInstance.namespaces.item(counter) = uniquestring then[code]....
but now i get Err.Number 91
View 9 Replies
View Related
Sep 12, 2006
I wrote some code which has compiled a LOT of text files telling me what computers have licence for certain software.
The name of the txt file is the computer name and data within is simple:
--------------------
Audit of GQL license
Audit of Visio license
Audit of Frontpage license
Audit of Project license
Audit of Visual .NET license
Audit of Word (Office) licenses
Found Office
--------------------
as we can see here this computer has 1 licence for OFFICE.
If the string "FOUND" is found then i want to be able to paste the licence name in a spreadsheet and in the next cell underneath paste the filename it was found in the e.g.
VISIO
comp1,comp2,comp3,comp4
WORD
Comp2, comp3, comp4, comp5....and so on......
View 9 Replies
View Related
Jun 5, 2009
is it possible to type a document name in a cell,then run a code that searches a root dir and sub folders, find the existing document and open it?? for example
cell: "D20"
filename: DYAZES-001
root dir: "I:IsolationDataBaseIsolationProcedures
subfolders: DryMillA, DryMillB, Despatch, Maintenance
View 5 Replies
View Related
May 6, 2009
I read in a txt file with the code below. There's some kind of special character in the last 3 lines of the input file that makes the macro crash. I don't need anything in those 3 rows. How can I delete them before my Do Until loop?
-----
Sub Mytxt()
Dim Mytxt As String
Mytxt = Application.GetOpenFilename(FileFilter:="EXCEL files (*.txt),*.txt", Title:="Open the Report file you need")
If Mytxt = "" Then Exit Sub
Workbooks.Open Filename:=Mytxt
Open Mytxt For Input As #1
i = 1
Do Until (EOF(1) = True)
Line Input #1, tempstr
Cells(i, 1) = Mid(tempstr, 23, 5)
Cells(i, 2) = Mid(tempstr, 25, 1)
Cells(i, 3) = Mid(tempstr, 33, 3)
i = i + 1
Loop
Close 1
End Sub
View 9 Replies
View Related
Nov 24, 2009
I have an excel template that needs to be copied multiple times and each sheet needs be named according to a list in an excel spread sheet. I also have a formula in the template that needs the value copied instead of the formula.
I got this script from an site and tried it. It runs but I don't see any spread sheets.
strComputer = "."
Set objWMIService = GetObject ("winmgmts:\" & strComputer & "
ootcimv2")
View 9 Replies
View Related
Oct 11, 2013
I am trying to write a macro to open a specific file, but need to search multiple folders within folders to find it.
The file name I need to open is "Escalation Adherence-Details " & Format(Date, "mm-dd-yy") & ".xlsx".
I need to drill down to the Adherence Report folder and then have the macro search through folders for each year (2012, 2013, 2014, 2015, etc) and then each month within each year (1 January, 2 February, 3 March, etc), at which point I would then find that day's file.
So far I have the following:
Code:
Sub Open_ESCL_Report()
Workbooks.Open Filename:=*****.****.****.******.comsharesPurchasingTeam XEscalationAdherence Report & "Escalation Adherence-Details " & Format(Date, "mm-dd-yy") & ".xlsx"
End Sub
Each file is stored in it's respective month folder as .....Adherence Report(Year)(Month)(File).xlsx
View 3 Replies
View Related
Jan 26, 2010
I cant seem to get the file filter to be what I want. I want to et the default file filter string to "MOT*.xls". With the code below I get "*.*" and no option for my own filter value.
View 6 Replies
View Related
Apr 8, 2008
I am changing the file type association for .XLS to
C:Program FilesMicrosoft OfficeOffice11excel.exe
I'm using "Change" and "browse" to set it to that exact file. However it still starts version 12 (XL2007) which is dual installed with version 11 (XL2003).
I was successful in creating a shortcut that opens version 11, despite Microsoft's apparent attempt to thwart that; now I need to fix the file association. (Try to directly edit the Office links in your XP Start Menu - how the target is grayed out?
View 9 Replies
View Related
Jun 6, 2012
I am getting a Type Mismatch Error when I run the following code.
I need to have the name save as
06-01-2012 dispositions.xlsx
in a specific location that is in this line of code. When i have it put 'dispositions' first, it works, but i need the date to show first in the name. Am I missing an additional function or quotes?
HTML Code:
ActiveWorkbook.SaveAs Filename:="C:DataSales TeamReview DatabseDispositions" & Year(Date) & "" & MonthName(Month(Date)) Format(ActiveSheet.Range("H1"), "mm-dd-yyyy") & "dispositions.xlsx", FileFormat:=51
View 4 Replies
View Related
Feb 20, 2014
I have the below code to have the user select a pile path and save. what can I add to have the dialog box preselect the file type to macro enabled? the .xlsm extension is not doing it.
['save it under a new name
Dim fPth As Object
Set fPth = Application.FileDialog(msoFileDialogSaveAs)
With fPth
.InitialFileName = Worksheets("Project Setup").Range("f19").Text & "_ROM Estimate.xlsm"
.Title = "Save your File:"
.InitialView = msoFileDialogViewList
.Show
End With]
View 4 Replies
View Related
Mar 21, 2014
is it possible to change the settings on your computer so that when you open Excel, it opens it as a certain type of file? I like working with .xlsb because I work with large sets of data all of the time and find that they open faster and are faster to work with. Currently every time I open Excel, it opens as .xlsx.
View 1 Replies
View Related
Apr 21, 2006
I've been searching all morning through various posts on this subject, but I can't find anything that I can adapt to my needs. Here is the code I have:
ChDir "C:Documents and SettingsmynameDesktop"
ActiveWorkbook. SaveAs Filename:= _
"C:Documents and SettingsmynameDesktopBook1.txt", FileFormat:=xlText, _
CreateBackup:=False
This file will be used accross multiple computers and therefore the directory will always change. What I need to hapen, is for this code to save the workbook in the same directory as the origional file. I also want the file name to refer to a cells value, as I will be having the user define the name through a userform.
View 4 Replies
View Related
Aug 16, 2008
I need to open about 2000 documents one at a time, and save them with a different name.
they are a mix of word documents, PDFs and .jpg pictures.
some VBA like:
Open.file strPath & nextfile
where strpath = C:Temp
and nextfile = picture01.jpg
What should the line be? or is it more complex than a single line ?
View 9 Replies
View Related
May 11, 2012
I have a folder with files in it. I want to copy the file names and past them into my Excel spreadsheet. This seems like it should be a simple task.
View 6 Replies
View Related
Dec 20, 2012
I bought a new computer with Windows 7. A file that is fine on my old unit does not work on the new one.
Column "H" should provide a list of birthdays comming up in the next two months, but something is not working.
View 4 Replies
View Related
Apr 25, 2014
What I need to do is put data that I get on a variery of excel speadsheets into a standard template. I can do this by the process of copying over column by column the appropriate detail from one workbook to the other.
what I'd like to do is replicate the column headings of the template onto the workbook with the original data so I'm looking at just one workbook all the while until I'm ready to transfer all the data in one go.
I realise I can just copy from the template to the active workbook, but what I had in mind was having the ability to hit a button to replicate it associated with a macro.
So the macro I'd want would involve starting from a cell in the active workbook, obtaining a named range from my personal workbook (which would be the template headings) and then pasting this back into the active cell of the active workbook.
And if it is feasible...how would I get it to work (taking into consideration the Personal workbook may be hidden).
the only code i have at the moment is
Workbooks("PERSONAL.XLSB").Worksheets(1).Range("MODELTEMPLATE").Copy
But how would I get this to paste onto the cell I start with?
View 5 Replies
View Related
May 5, 2012
I want to copy the sheet named "data" from closed workbook (xlsm, xlsx, xls) via ADO.The closed workbook will be choosen by user via dialog box. The code must check the existence of "data" sheet. If there is no, then the code must give a warning. Futhermore, which is able to give a warning against the mistake of selecting the file itself.
View 1 Replies
View Related
Jan 26, 2009
I have a macro that I found somewhere on the net to look within a folder and list all the files of a certain file extension.
The macro to do this is in the attached example and is called 'Get_File_Names_Within_Dir_ext'.
I have created a basic userform outline, 'UF1' for the user to define:
Select File Extension
Select Folder to Search
Destination Sheet
I just don't have any idea how to sync the two.
If you type 'exe' into 'TB1_File_Extension' of 'UF1' the macro should search for '*.exe' files within the specified folder.
The search folder 'RefEdit1' box should open a windows explorer box (or some such) so that the user can select the directory in which to search for the previously specified file extension.
'TB2_Destination_Sheet' is a text box for the user to type the sheet within the workbook in which to list the files found within the specified directory.
'CB1_Find_Files' should activate the macro to find any files for the specified criteria.
There is also a Button 'Find File Types' in Sheet1 of the file which should activate the userform 'UF1'.
View 14 Replies
View Related
Feb 22, 2009
i made a macro that uses a form with a "browse" button to open a text file and put every word in this textfile in a single cell but i had a problem when copying the address of the file to a textfield, here's the code :
View 5 Replies
View Related
Dec 18, 2012
I currently have a code that copies (when both workbooks are open) the status report tab from one workbook to another. So, my code copies the entire "Status" tab from Report.12102012.xlsx to Master_Report.xlsx.
But, there will continually be new Report.(DATE).xlsx files that are being made and I would like for my code to be able to search for the newest date "Report" spreadsheet, open it (so employee doesn't have to find the newest spreadsheet), and then copy the "Status" tab to my Master_Report.xlsx file.
All of the "Report.(DATE).xlsx" files will be stored in the same folder.
View 3 Replies
View Related