Copying data from one excel workbook to another -
i trying write code uses button click grabs data input workbook , pastes in output workbook. problem cant figure out input workbooks name changes date in same naming convention. want code pull latest date input file , paste in output workbook. have no idea start.. appreciate.
thanks
i agree ken: ask in single question. "grabs data input workbook , pastes in output workbook" mean anything. however, function use solve first part of requirement. parameters folder name , file template. returns name of newest file within folder matches template.
function newestfilename(byval path string, byval filetemplate string) string ' * finds, , returns name of, newest file in folder path name ' matches filetemplate. returns "" if no matching file found. ' * path folder in search files ' * filetemplate file name specification of file required. example: ' myfile*.xls ' 25jul11 copied riskregistercontrol v43.xls. ' 22nov11 name changed newestfile newestfilename match nextfilename. ' 20apr12 minor improvements dim filedatecrnt date dim filedatenewest date dim filenamecrnt string dim filenamenewest string if right(path, 1) <> "\" path = path & "\" end if filenamecrnt = dir$(path & filetemplate) if filenamecrnt = "" newestfilename = "" exit function end if filenamenewest = filenamecrnt filedatenewest = filedatetime(path & filenamecrnt) while true filenamecrnt = dir$ if filenamecrnt = "" exit filedatecrnt = filedatetime(path & filenamecrnt) if filedatecrnt > filedatenewest filenamenewest = filenamecrnt filedatenewest = filedatecrnt end if loop newestfilename = filenamenewest end function
Comments
Post a Comment