keeping in mind that the document is pretty much a database and analysis tool for the data inside and there's a lot of information that goes around through sheets, sheets are constantly created, modified etc. So when calling my macros, I want to make sure it will look for the right sheet (I want to get rid of anything of the likes of ActiveSheet).Ĭalling this function would therefore be more of a way of creating something stable to call the activesheet and make sure this sheet corresponds to the "type" that it should be. It will be used by completely unexperienced Excel users so I need to make sure it doesn't break with them doing crazy inexplicable sheet name changing, swiping their positions for no reason and so on. Well I guess talking about my own issue would officially be highjacking the post, but personally I have a spreadsheet with two different types of worksheets, which I have renamed (codenames) to S0, S1. Thanks to both of you for the quick answers ! I don't really understand what your issue is?
#API VBA WORKSHEET NAME CODE#
The Index is simply used to get a reference to the right sheet from the VBComponent, which is identified using the code name. You pass the code name to the function, so you still have the advantage of the code name. But I can't really do it that way as the worksheets are not generically named for the purposes of the user. Obviously one solution could be to use the worksheet name rather than the codename and then the above, in theory (if sSheetCodeName was replaced with Sheets(sSheetCodeName) ), would work fine if sSheetCodeName had the same value as the worksheet name. range("Value of StringVariable") ).īut is there anyway I can get it to recognise a variable as a worksheet codename. b) Line 4 - Since by default after copying sheet, the copied sheet is activated, ActiveSheet object could be used to rename the copied WorkSheet. T he attached vba form and code should get you going. ActiveSheet is copied and moved to end of the workbook. If you are linking/embedding your spreadsheet, you dont need to call it explicitly, since it is part of your Inventor file. I appreciate the above doesn't work because the codename isn't a string so I can't use this to reference the sheet in the same way you could use a string to reference a named range ( i.e.range(StringVariable) can be used to replace. To do it in Excel, here is the answer: a) Line 3 - represents the last sheet. The codenames of these sheets are all SQL1-10. So the problem is at the end, part where I'm trying to activate the relevant SQL Output Sheet.
#API VBA WORKSHEET NAME SERIES#
If you need to copy a worksheet multiple times, and give them series names, such as KTE-1, KTE-2, KTE-3, KTE-4, the following VBA code can do you a favor. 'Copies the contents of the named range onto the clipboard Copy a worksheet multiple times and rename them with increment tab names by using VBA code.