vba - Excel macro causes corruption to workbooks it pastes to -
i'm working on macro copy input values user (in table on sheet, not prompt) , pastes them specific target workbooks. code seems work once , in working happens target workbooks , error saying files format or extension not valid. these design tables solidworks , open fine when solidworks references them though. can me figure out why happening? here code.
sub copysalesinfo() 'turn off screen updating 'application.screenupdating = false 'copy input sales driver sheets 'define dims dim wkbksales workbook dim wkbkmasterdriver workbook dim wkbkdoorformingdriver workbook dim wkbkdoorasmdriver workbook dim wkbkboxasmdriver workbook dim salessheet worksheet dim masterdriversheet worksheet dim doorformingdriversheet worksheet dim doorasmdriversheet worksheet dim boxasmdriversheet worksheet 'set workbook , worksheet locations (hard code) set wkbksales = thisworkbook set wkbkmasterdriver = workbooks.open("s:\aluminum\box configurator\test 20x box config plain\20x master driver.xlsx") set wkbkdoorformingdriver = workbooks.open("s:\aluminum\box configurator\test 20x box config plain\door, pl, forming driver.xlsx") set wkbkdoorasmdriver = workbooks.open("s:\aluminum\box configurator\test 20x box config plain\door asm driver.xlsx") 'set wkbkboxasmdriver = workbooks.open("s:\aluminum\box configurator\test 20x box config plain\box asm driver.xlsx") set salessheet = wkbksales.worksheets("sales config sheet") set masterdriversheet = wkbkmasterdriver.worksheets("sheet1") set doorformingdriversheet = wkbkdoorformingdriver.worksheets("sheet1") set doorasmdriversheet = wkbkdoorasmdriver.worksheets("sheet1") 'set boxasmdriversheet = wkbkdoorasmdriver.worksheets("sheet1") 'copy data salessheet.range("c3:c11").copy 'paste data sheets masterdriversheet.range("t10").pastespecial xlpastevalues doorformingdriversheet.range("n11").pastespecial xlpastevalues doorasmdriversheet.range("m8").pastespecial xlpastevalues 'boxasmdriversheet.range("m8").pastespecial xlpastevalues 'save driver files wkbkmasterdriver.save wkbkdoorformingdriver.save wkbkdoorasmdriver.save 'wkbkboxasmdriver.save 'close driver files wkbkmasterdriver.close wkbkdoorformingdriver.close wkbkdoorasmdriver.close 'wkbkboxasmdriver.close end sub
Comments
Post a Comment