Hello,
I know what causes it but cannot get it to work. Probably simple but my VBA knowledge is not enough.
I build a macro that formats a data dump from a system so it is usable. Remove colums, move colums, insert colums, make data readable with concatenate, format cells, set filter etc.
At one point I open a Template xlsx (same directory), Copy a Worksheet to ThisWorkbook, close that Template again and use data from that new inserted Worksheet to sort further.
The macro works perfectly, but only when I paste into the Workbook itself. After that I pasted it into Personal.xlsb to have it available for reuse and then it goes wrong.
I found out that it has to do with ActiveWorkbook or ThisWorkbook that acts as if Personal is the sheet/workbook to work from. ThisWorkbook is the one with the code... so Personal.
How to get around this, it should work on the open Workbook, not the Personal.
I tried all sorts of things with ActivesWorkbook and ThisWorkbook, declare dim for ActiveWorkbook.Name and use that to get onto the Open Workbook but all runs into VAB errors.
ActiveWorkbook.Save
Workbooks.Open ("H:\...\Macro\Kostenoverzicht template.xlsx")
Windows("Kostenoverzicht template.xlsx").Activate
Sheets("06 nummer en naam").Select
Sheets("06 nummer en naam").Copy After:=ThisWorkbook.Sheets(1)
Windows("Kostenoverzicht template.xlsx").Activate
ActiveWorkbook.Close SaveChanges:=True
Has anyone a neat trick to get this code to also work from Personal.xlsb?
Thx for now already...
Greetings, Zand
I know what causes it but cannot get it to work. Probably simple but my VBA knowledge is not enough.
I build a macro that formats a data dump from a system so it is usable. Remove colums, move colums, insert colums, make data readable with concatenate, format cells, set filter etc.
At one point I open a Template xlsx (same directory), Copy a Worksheet to ThisWorkbook, close that Template again and use data from that new inserted Worksheet to sort further.
The macro works perfectly, but only when I paste into the Workbook itself. After that I pasted it into Personal.xlsb to have it available for reuse and then it goes wrong.
I found out that it has to do with ActiveWorkbook or ThisWorkbook that acts as if Personal is the sheet/workbook to work from. ThisWorkbook is the one with the code... so Personal.
How to get around this, it should work on the open Workbook, not the Personal.
I tried all sorts of things with ActivesWorkbook and ThisWorkbook, declare dim for ActiveWorkbook.Name and use that to get onto the Open Workbook but all runs into VAB errors.
ActiveWorkbook.Save
Workbooks.Open ("H:\...\Macro\Kostenoverzicht template.xlsx")
Windows("Kostenoverzicht template.xlsx").Activate
Sheets("06 nummer en naam").Select
Sheets("06 nummer en naam").Copy After:=ThisWorkbook.Sheets(1)
Windows("Kostenoverzicht template.xlsx").Activate
ActiveWorkbook.Close SaveChanges:=True
Has anyone a neat trick to get this code to also work from Personal.xlsb?
Thx for now already...
Greetings, Zand