Hi i have created a macro the inserts a pivot and set the fields and values but excel creats a new sheet and the number goes up by 1 ie sheet 1 next is sheet 2 but my macro looks for sheet1
The macro will create new sheet with sequential number, hence you should not specify as sheet1 instead you have mention as activasheet. The macro creates a new sheet and activated.
Remove these 2 line
Sheets("sheet1").select
sheets("sheet1").name="Pivot1"
Hi i have created a macro the inserts a pivot and set the fields and values but excel creats a new sheet and the number goes up by 1 ie sheet 1 next is sheet 2 but my macro looks for sheet1
thanks for the replys my work around was to save the exel book as a template then it always produced a sheet 1 every time you open it and try and save.
it could be that i did not explain my problem fully i will upload a sample the proccess goes like this
open macro work book
copy data from data extract
Paste into Macro work book
Run Macro Ctr+m removes and insert named columns
Run Macro Ctr+b insert pivot table sorts data... Great
Run Macro Ctr+q clears main data ready for next day
Copy data extract
Paste into Macro Book
Run Macro Ctr+m removes and insert named columns
Run Macro Ctr+b Error as its looking to insert Sheet 2 Now and name it Pivot 1 i already have this..
the book i uploaded has the data as the desk clerk has just pasted the data in No2
any help is appreciated