Excel VBA Dim a new -
i'm new vba coding , i'm getting hung how navigate between sheets. have workbook contains single sheet , sheet copied new workbook can edited without damaging origianl. issue i'm having when new work book created need copy informaton 3rd workbook , paste new one. i've tried number of things haven't been able figure out. think issue new book doesn't have name book# once leave activate other book don't have solid path back.
sorry lack of actual example. have added first 2 lines based on response received.
dim wb workbook set wb = activeworkbook ' open 3rd workbook & copy workbooks.open ("z:\terms , conditions.xlsx") windows("terms , conditions.xlsx").activate activesheet.shapes.range(array("picture 4")).select selection.copy ' return wb , paste activeworkbook(wb).activate 'the code stopping here worksheets("sheet1").activate range("a534").select activesheet.paste
it see code if copying sheet create new workbook can store reference activeworkbook
dim wb workbook set wb = activeworkbook
and refer wb later in code required
Comments
Post a Comment