Hey all,

Just wondering if anyone can help me with this bit of code. I have fixed it that many times, i've changed the variable type and each time I change it, it will work maybe for a few days if that then it will reoccur. Does anyone have the propper way of doing this?

Pretty much it's grabbing the position the sheet sits on and stores it in a variable so that way when I create the new sheet it goes back in the same place. When it works it works well. I've tried dimming 'SheetPosHold' as variant, long, string, double, just dimming it, my last attempt was using the Clng() to convert it, which worked for a bit but now isn't again. (publicmodule.psheet = the sheet name)

SheetPosHold = CLng(Sheets(PublicModule.Psheet).Index)
What i have observed is if i hover over the equation it will show the number, but it won't pass it onto the variable. It doesn't matter what sheet it is, it feels random, which is the annoying part. If i remember correctly is is a type mismatch error.

If anyone has another way of doing this let me know.

Thanks,

Thomas