Import Macro ..
Jul 1, 2009
I have only ever created macros in existing workbooks. Is there an easy way to copy a macro from one workbook to another, without having to run a new macro in the new workbook and then paste the code into it from the old workbook?
View 7 Replies
ADVERTISEMENT
Jan 27, 2010
Macro to export and import a module and assigning different macro automatically ...
View 9 Replies
View Related
Oct 31, 2011
I have managed to come up with the following macro. The problem I have is that some of the data are imported in text format, while other data are imported in general format.
I have a large data set, with more then 5,000 rows, and 2,000 columns, and I would like ALL the data imported at text. How can I modify this macro to make that happen?
Code:
Sub ImportData()
With ActiveSheet.QueryTables.Add(Connection:= _"TEXT;C:Users*****ATTRIBUTES-ModifiedExport.csv", Destination:=Range("$A$1"))
.Name = "ATTRIBUTES-ModifiedExport.csv"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
[Code]...
View 1 Replies
View Related
Jan 29, 2014
I wish to click on a button in a worksheet which then looks in a particular folder on the local drive. Any file with a .xml extension import into the worksheet.
What if 2 or more xml files are present? The xml file filename ends with the date & time the file was generated, eg BPSEvent_10033_Tam_20140116124216
Can a code look for the oldest file to import based on the end of the filenaming format - yyyymmddhhmmss
Code to then delete the last xml file imported would be good too.
View 14 Replies
View Related
Jan 13, 2012
The following code (blue font) finds specific worksheets in an active workbook, and copies them into a new workbook then names the new workbook the same name of the worksheet. It all works perfectly.
The second code below (red font) imports some vb into the new workbook. It works fine if I manually open the new workbook and run it in the immediate window. However, I would like to incorporate the red code into the blue code so it all runs as one. I've tried inserting the red line after the "ws.copy after" line and after the ".saveas" line, but no dice.
For Each ws In wb.Worksheets
If UCase(Left(ws.Name, 2)) = "CC" Then
Set NewBook = Workbooks.Add
[Code]...
View 9 Replies
View Related
Dec 20, 2006
I would like to have a macro that will allow me to browse to the desired file and import the data into columns. I have the macro working to the point of allowing me to browse, select the file, and pasting the contents into the active sheet.
The things that I need help with are:
1. Getting the data to paste into a specific cell instead of A1. Currently the code is
CELLS.SELECT
ACTIVESHEET.PASTE
I would like the data to start in A7.
2. Getting the file parsed into columns. The format of the .DAT file is static and only has 4 columns. Currently when it imports, the entire record (row) all of the data is in the same column. I would like it separated into individual columns if possible.
View 9 Replies
View Related
May 13, 2008
1. I've recorded a macro that imports values from 6 different .csv files at once. The problem is that not all of these files are going exist upon import. Is there a way to tell the macro to only import if the file exists? And to skip if the import of that file if it doesn't exist? Right now the debugger stops the macro because of file not found.
2. I want to press a button on Sheet 1 that copies Sheet 1 into a new Sheet that's named with today's date. E.g. I press the "Archive"-button, the sheet is copied to a new sheet with the name "051308".
View 9 Replies
View Related
Aug 24, 2008
I have a TXT file that is properly format for a nice print out but not in any fashion to work in an excel or access file.
My txt file looks something like this
Header info Row 1
Header info Row 2
Header info Row 3
ACCT# Value Descripton ~ Part number
Customer Name ~ Vendor Name
Customer add1 ~ Vend add1
Customer add2 ~ Vend add2
Custom city, st, zip ~ vend city, st, zip
Repeat about 5 or 6 more entries
do a page bread and repeat the headers and then 5 or 6 more entries
I want to automatically copy the entries and place the data into Row 1 of Excel starting in Column 1 through Column 12
Then the 2nd entry would be in row 2 etc
View 9 Replies
View Related
Jun 16, 2006
I'm trying to create a macro that will import data from another excel
file, into my current excel file.
Basically, I see the process going as follows:
1. Run Macro via Button
2. Pop-Up Window asking for File Location (importBook)
3. Import Data from importBook into sheet entitled Data
4. Click OK once import is complete
I've got some knowledge of coding but macro coding knowledge is
limited. If anyone has an existing code or can whip one up, I would be
very appreciative.
I started out with this
Dim filename As Variant
filename = Application. GetOpenFilename()
Workbooks.Open filename
View 8 Replies
View Related
Mar 13, 2007
I did a macro the import a log file from a specific directory and now i want that the user could enter the path of the directory that contain the file Is there a way to do it?
ub ALL_Logs_files()
'
' Logssss Macro
' Macro recorded 3/4/2007 by dzaitoun
'
Sheets.Add
ActiveSheet. Name = "Foresight FP Data"
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:Documents and SettingsdzaitounDesktopLog out filesforesight.fp.out" _ , Destination:=Range("A1"))
.Name = "foresight.fp"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True ..............
View 4 Replies
View Related
May 24, 2007
I have found several examples of excellent macro code on this site.
Is there a procedure to import a macro code ( saved as a TXT file) into the Personal.xls file?
For example, the following code removes blank spaces and converts text to proper case.
Is there an easy way to save this as a macro in my Personal.xls file?
'Macro Code to apply TRIM and PROPER functions on the selected range ..
View 8 Replies
View Related
Jul 11, 2008
I've got a basic handle on the application/use of macros, & personally use them for cleaning up data exported from a very very old as400esq application.
My problem is that i have managed to clean up all the blank data & piffle, but Im stupped by the header part of the text dump.
Heres an example;
A B C D E F
-------------------Header A-------------
1 3 john 50 piano
4 1 Bill 25 horn
6 5 Ted 60 trumpet
-------------------Header B-------------
3 3 Phil 71 Cello
1 1 James 83 Viola
3 2 Earnie 62 Violin
I basically want to rid the header rows from the spreadsheet & drop the header description (Header A/ Header B) into column F for all those items below until you get to the next header.
View 14 Replies
View Related
Sep 29, 2009
I need to import a number of log files into a spreadsheet, each log will go into a separate tab. The logs are text files (.log) that have the same structure but slightly differ from each other.
For example all the logs will have many lines of data all starting with a date and then a number of delimited fields. In some logs the delimiter is a coma, in others is a unique charachter such as "{" or "@". Also the delimited fields are not a given quantity, they can vary too from log to log. How can I write a macro that understands what delimiter needs to be used and then imports all the file accordingly into one spreadsheet (in separate tabs)?
I tried something with the macro recorder and browsed for directions on the internet but really am clueless on this one. I am using windows 2000, and referenced Windows Scripting Runtime.
View 3 Replies
View Related
May 17, 2011
I'm looking for a macro that will import multiple .csv files from c: emp each into their own separate worksheet.
View 5 Replies
View Related
Dec 13, 2013
I need a macro that import tabs from a file into another file.
View 1 Replies
View Related
Mar 25, 2007
I want to automate the download process of these scan files we use. I can figure out how to do that if not for the two wildcards I'm about to throw out.
What I can't seem to figure out is how to use VBA to determine which files to import. I was thinking about possibly having VBA look for the time stamps on these files in the scan file directory, and then only import those ones which created in less than an hour from current time.
I have only a few days of VBA experience, so I don't have a clue where to start. If anyone could provide assistance/point me in the right direction.
By the way, the files that I am importing will be a comma delimited file. However, for some reason, the files are all extensionless (without .xxx)
View 9 Replies
View Related
Apr 24, 2009
I tried to adapt this code into my own from another thread. [url]
BUT, I am getting an error when running it. On the "For i" line. And I know just enough VBA to be dangerous. Can someone help?
I have another code setup to run if a certain cell equals "October" then it calls ImportData. Then this code is supposed to pull all files out of My documents/TechConnect/October08 and place the data into sheet 1....
View 9 Replies
View Related
Oct 19, 2006
I am trying to use a dynamic VBA code to import data into a xcel sheet from another sheet. I currently have it working but in the code I have the directory and the file name listed for the file to be imported. I would like to change this to a cell referance inside my sheet so that I can make changes to the name of the file or the directory location and the VBA code would use the cell reference as the source data.
View 9 Replies
View Related
Oct 30, 2006
how to make a button(s) which will import data. I have to make a report and import some cells from 350 other excel files. Report is attached to this post. In the yellow cells should be buttons. The code for first one is :
Sub CopyRanges() ....
View 4 Replies
View Related
Dec 11, 2006
Can we create a macre that can convert txt file into excel.
View 5 Replies
View Related
Jan 15, 2007
after importing data (data >> get external data >> import text file) and running a macro that contains
Cells(i, 5).EntireRow.Delete Shift:=xlShiftUp
i cannot insert any data into the next column below. why is this so? is it because of the excel memory that remembers that a macro has been previously ran in that cell before? example i import text file into B1 then the data will be imported into different cells using delimiters. the data will occupy from row 1 to 22. After i run the macro which combines fields with similar data the data will occupy row 1 to 15. then when i try to import data into B16. the "import text file" option will be grayed out. why is this so? how do i solve the problem?
View 4 Replies
View Related
Mar 27, 2008
I'm trying to import a text file with an Excel 4 macro. I tried the Open.Text function but I cant assign a date (YYYYMMDD) format to the first field.
View 4 Replies
View Related
Jan 29, 2008
I'm attempting to import around 200 (and growing!) separate text files into Excel. I am using the formula below to import the text file and then using a separate macro to select the information I need, copy it into another spreadsheet, and then run the import macro again.
However, I have a problem in that my import macro gives me 'Run-time error '1004:
Application defined or user defined error''. At first this wasn't a problem as the information is pasted into the spreadsheet despite the error anyway. However, now that I am looping the macro it is obviously causing more problems as it prevents the loop. I would really appreciate it if anyone knows of a work-around or can spot an error in the coding to resolve this!
The code below shows is for the import macro only:
Sub ImportTextFile(FName As String, Sep As String)
Dim RowNdx As Long
Dim ColNdx As Integer
Dim TempVal As Variant
Dim WholeLine As String
Dim Pos As Integer
Dim NextPos As Integer
Dim SaveColNdx As Integer
View 8 Replies
View Related
Sep 20, 2012
I have 400+ workbooks in a folder. If they are all .xlsm (macro-enabled) workbooks, how can I import a macro (.cls file) to a particular sheet (sheet1) in each workbook using VBA so that when a user on another machine opens one of them, the macro works? Right now, I have this code to loop through all workbooks; I only need the import function to go in the middle. Copying and pasting or importing manually 400+ times is just plain unrealistic!
VB:
Sub OpenfileUpdate()
Dim strFile As String
mFolder = "C:files1Files"
strFile = Dir(mFolder & "*.xlsm*")
Do While strFile <> ""
[Code]....
View 9 Replies
View Related
Jul 3, 2014
I've got a spreadsheet listing applications on PCs (assets), one line per application, and need to import that info into another document for each PC and save it with a file name which = the PC name (asset number). I've attached a couple of sample files to try to explain what i mean.For asset number PC037014 I need the corresponding fields filled and the list of applications pasted under where is says Additional Software List (inserting more rows if there are too many applications to fit in). Once the information has been populated, i'd like the file to be saved in a specific folder then move onto the next asset number in the list.
View 13 Replies
View Related
Mar 19, 2014
I have recorded the following macro to import a text file. code or show a new way of importing the same. Also i can't figure out how to remove the unwanted rows and unwanted headers after importing the text fle.
Sample file is attached below.
[URL] .....
The macro that i have recorded :
[Code] .....
View 14 Replies
View Related
Oct 29, 2009
I have recorded a macro to import web data, from a sporting site,
problem is URL is date and event specific.
View 10 Replies
View Related
Jan 13, 2010
Attached is a workbook that takes an imported text file, inserts rows with text.
It is SLOW, you can watch each line being inserted with the text, I would think with such a small sample dataset it would be much much quicker.
Information: See attached xls file.
On sheet1 is the imported data, sheet2 is a copy of the imported data so one can copy and paste to sheet1 as needed with out re-importing for test purposes and only for this query. (Sheets2 thru 3 are not used otherwise).
There is a command button on sheet one which will run macro "aaa". If you run this you will see how slow it is and exactly what it is doing.
I am simply looking for a way to speed this up, I have some files that are 10 times the size of the sample data and they take 10 or more minutes to run.
View 10 Replies
View Related
Jun 27, 2013
I've created an Auto_Run macro that imports a CSV file into a specified worksheet. That worksheet is referenced by VlookUp in another worksheet within the workbook. Everything works perfectly EXCEPT, in the midst of running the macro, the user is prompted to (RE)choose the csv file already specified in the macro. Neither the folder nor the filename ever changes, so I'm not sure why I have to keep indicating the file every time the macro runs.
PHP Code:
'Sub Auto_Run() ' ' Auto_Run Macro ' ' Sheets("CSVData").Select Cells.Select
Selection.Delete Shift:=xlUp With ActiveSheet.QueryTables.Add(Connection:= _ "TEXT;
G:TestProjectsWorkOrderTest.csv", Destination:=Range("$A$1"))
.Name = "WorkOrderTest" .FieldNames = True .RowNumbers = False
[Code] .......
View 7 Replies
View Related
Jun 11, 2014
I've never actually had a reason or need to use macros for data import or manipulation. At the moment I'm trying to work on a modeling problem which will output the data in the form of a large text file. The data is divided up using 1000 energy bins, and 1000 timing bins for each tally (unique set of output data) like in this file [URL].....Unfortunately because of the applications for the data I can't reduce the number of bins, and the software being used for the modeling will not provide a more convenient form for the output file.
How to create a macro that can extract this data from the output file and import it into a designated excel spreadsheet. It would be preferable to import each set of tally data from the initial output file into it's own spreadsheet, but as I said I have no experience using macros and I'm not even sure where to begin in making something that would work. or even a basic source for examples
View 1 Replies
View Related