VBA for Excel - finding path of a list of file -


i'm not yet on vba coding need speeding work. need:

snapshot

column (what provide): list of file

column b (what i'm looking for): path of file

can give me advice? think should simple code don't know yet how start. thank in advance.

regards, andrea

here's more information...

input:

1234xx12345_sheet3_2

output:

1234xx12345_sheet1_2

1234xx12345_sheet2_2

1234xx12345_sheet3_2

while "expand" number of sheet i'd search in directory , write path. hope it's clear enough ^^'

public function lastrow(colonna string) long lastrow = activesheet.cells(rows.count, colonna).end(xlup).row end function  public function lastcol(riga integer) long lastcol = activesheet.cells(riga, columns.count).end(xltoleft).column end function  public function recurse(spath string) string  dim fso new filesystemobject dim myfolder folder dim mysubfolder folder dim myfile file  set myfolder = fso.getfolder(spath)  each mysubfolder in myfolder.subfolders     each myfile in mysubfolder.files         if myfile.name = range(foglio1.cells(ultimax, 2)).value             foglio1.cells(ultimax, 3) = myfile.path             exit         end if     next     recurse = recurse(mysubfolder.path) next  end function 

and command box:

private sub commandbutton1_click() dim ultimax long dim n_sheet integer dim iso string  foglio1.range("b2:b1000000").clear  ultimax = 2 = 2 lastrow("a")     = split(foglio1.cells(i, 1), "_")     n_sheet = replace(a(1), "sheet", "") * 1     j = 1 n_sheet          foglio1.cells(ultimax, 2) = a(0) & "_" & left(a(1), 5) & j & "_" & a(2) & ".pdf"         call recurse("c:\users\vvvvv\desktop\test_vb")         ultimax = ultimax + 1     next j next msgbox "finish!!" end sub 

ok i've found solution, work many folder , files takes way long end process, how speed it? here's code:

public function lastrow(colonna string) long lastrow = activesheet.cells(rows.count, colonna).end(xlup).row end function  public function lastcol(riga integer) long lastcol = activesheet.cells(riga, columns.count).end(xltoleft).column end function  public function recurse(spath string, pp long) string  dim fso new filesystemobject dim myfolder folder dim mysubfolder folder dim myfile file  set myfolder = fso.getfolder(spath)  each mysubfolder in myfolder.subfolders     each myfile in mysubfolder.files         if myfile.name = foglio1.cells(pp, 2)             foglio1.cells(pp, 3) = myfile.path             exit         end if     next     recurse = recurse(mysubfolder.path, pp) next  end function   private sub commandbutton1_click() dim ultimax long dim n_sheet integer dim iso string dim pp string   foglio1.range("b2:b1000000").clear foglio1.range("c2:b1000000").clear  ultimax = 2 = 2 lastrow("a")     = split(foglio1.cells(i, 1), "_")     n_sheet = replace(a(1), "sheet", "") * 1     j = 1 n_sheet         foglio1.cells(ultimax, 2) = a(0) & "_" & left(a(1), 5) & j & "_" & a(2) & ".pdf"         call recurse("c:\users\ddddd\desktop\folder\", ultimax)         ultimax = ultimax + 1     next j next msgbox "finish!!" end sub 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -