Excel VBA Delete Column from imported worksheet -



Excel VBA Delete Column from imported worksheet -

i using code import worksheet closed file. 1 time import finish want delete column worksheet , switch primary worksheet. tried using columns(4).delete , entirecolumns.delete there no error , excel takes no action. ideas on improve way this?

'this code handles import of info sub importfile() 'definitions dim fileimport string dim srcbook workbook ' turns off screen updating application.screenupdating = false application.enableevents = false ' file path fileimport = "path" 'opens book set sourceb = application.workbooks.open(fileimport) 'copys sheet sourceb.sheets("miscellaneous holds").copy after:=thisworkbook.sheets (thisworkbook.sheets.count) ' closes book srcbook.close true 'enables screen edit application.screenupdating = true application.enableevents = true sheets("main").activate end sub

this maybe not working if not qualifying sheet in columns(4).entirecolumn.delete statement...

so utilize sourceb.sheets("miscellaneous holds").columns(4).entirecolumn.delete instead....

if don't want these changes saved in source workbook alter savechanges parameter false.

'this code handles import of info sub importfile() 'definitions dim fileimport string dim srcbook workbook dim srcsheet worksheet ' turns off screen updating application.screenupdating = false application.enableevents = false ' file path fileimport = "path" 'opens book set srcbook = application.workbooks.open(fileimport) set srcsheet = sourceb.sheets("miscellaneous holds") srcsheet.columns(4).entirecolumn.delete 'copys sheet srcsheet.copy after:=thisworkbook.sheets(thisworkbook.sheets.count) ' closes book srcbook.close false 'enables screen edit application.screenupdating = true application.enableevents = true thisworkbook.sheets("main").activate end sub

excel vba excel-vba

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -