Excel VBA - Copy entire columns from closed Workbook -


i've got excel workbook lot of information want pull out , insert new workbook macro contained.

what i'm after general function takes couple of arguments sourcefile , column. need columns, entire column source file.

this how i'm picturing function (pseudo code)

public function getcolumnfromworkbook(byval strsourcefile, byval sourceworksheet)     application.screenupdating = false     set wb = workbooks.open(strsourcefile, true, true)      thisworkbook.worksheets(destsheet)         .column(1) = wb.worksheets(sourceworksheet).columns(sourcecolumn)     end         end function 

the function above don't work. might show i'm after :)

this seems work me - note have extended parameter list. no error checking.

public function getcolumnfromworkbook(byval strsourcefile string, byval sourceworksheetname string, byval sourcecolumn long, byval destsheet worksheet)      application.screenupdating = false      dim wb workbook     set wb = workbooks.open(strsourcefile, true, true)     wb.worksheets(sourceworksheetname).columns(sourcecolumn).copy (destsheet.columns(1))     wb.close      application.screenupdating = true  end function 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -