Excel VBA or Function to extract Workbook name and data from workbook -


is there way extract workbook name, extract part of it. version of excel fine preferably 2003.

for example

"help_ticketid123456788.xls"   "help_ticketid563565464.xls"  

...

so i'd extract id numbers , put them column on master worksheet in workbook.

additionally i'd extract data specific columns (always same columns) each workbook, , put master worksheet too.

thank you!!

in master spreadsheet can write vba procedure loop on xls files in directory, extract id number each filename, , open each file extract other data. should started:

sub runcodeonallxlsfiles() dim lcount long dim wbresults workbook dim wbcodebook workbook  application.screenupdating = false application.displayalerts = false application.enableevents = false  on error resume next set wbcodebook = thisworkbook     application.filesearch         .newsearch         'change path suit         .lookin = "c:\mydocuments\testresults"         .filetype = msofiletypeexcelworkbooks         'optional filter wildcard         .filename = "help_ticketid*.xls"             if .execute > 0 'workbooks in folder                 lcount = 1 .foundfiles.count 'loop through                     'extract ticket #                     '.foundfiles(lcount) filename                      'open workbook x , set workbook variable                     set wbresults = workbooks.open(filename:=.foundfiles(lcount), updatelinks:=0)                      'read data wbresults , write master spreadsheet                      wbresults.close savechanges:=false                 next lcount             end if     end on error goto 0 application.screenupdating = true application.displayalerts = true application.enableevents = true end sub 

source: http://www.ozgrid.com/vba/loop-through.htm


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -