Paste (or type) the above macro into the code window.Right-click the worksheet tab and select View Code from the resulting Context menu.Open a new workbook that has only one worksheet in it.To set up this macro, follow these steps: & "It appears to contain one or more " & Chr(13) _ MsgBox "Please revise the entry in A1." & Chr(13) _ Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) What if you want a more robust macro that does check for errors and runs automatically? The result is a bit longer, but still not overly complex: This means that if A1 contains a value that would be illegal for a tab name then the macro generates an error. First of all, there is no error checking. There are several important items to note about this macro. For instance, the following macro will change the tab name to the contents of A1:ĪctiveSheet.Name = ActiveSheet.Range("A1") It is a relatively simple task to develop such a function using a macro that will do the job for you. Unfortunately, Excel doesn't provide an intrinsic function to handle this sort of task. What if you want to do it dynamically, however? What if you want to have the value in cell A1 automatically appear as the tab name? You probably already know that you can change the name of a worksheet tab by double-clicking on the tab and providing a new name.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |