Hi,
I'm trying to solve a problem with what I hope will be an easy fix. I manage a lab where we have to do lots of data entry for multiple tests. I create excel templates that the user (lab techs) must fill-in each template's set up page with the QA tracking ID (its' a combination of the Lab notebook,Page, & code i.e., EXP20-AA1234-A, EXP20-AA1234-B, etc.). Depending on the test method and the associated instrument, each data entry processes differ.
For one such test method, I need the template to rename the individual worksheets (tabs) used for importing the data into for each unique code. Leaving this up to the lab techs has proven problematic, in that they frequent forget to rename each tab; or they enter the wrong sample ID.
On the setup tab, I've got a formula that creates each sample name to be used; and named each of the resulting names for lookup (e.g., first generated name ="Tab_01", second generated name ="Tab_02", etc. up to Tab_25), and then I've linked each with a formula in cells A1 for each of the 25 tabs in the workbook template.
The problem is... the VBA code below only works with hard text in cell A1 but not a lookup formula. Is there some way to write the VBA code so that if the lookup value does not equal "Tab_01", etc. (for each of the 25 tabs) that it will change the sheet name to the resulting tab ID name? -or possibly be written to execute a macro to paste value(s) once it's changed?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
ActiveSheet.Name = ActiveSheet.Range("A1")
End If
End Sub
I'm not proficient with VBA code, so detailed solution example would be appreciated.
Thanks in advanced for any assistance.
Michele
I'm trying to solve a problem with what I hope will be an easy fix. I manage a lab where we have to do lots of data entry for multiple tests. I create excel templates that the user (lab techs) must fill-in each template's set up page with the QA tracking ID (its' a combination of the Lab notebook,Page, & code i.e., EXP20-AA1234-A, EXP20-AA1234-B, etc.). Depending on the test method and the associated instrument, each data entry processes differ.
For one such test method, I need the template to rename the individual worksheets (tabs) used for importing the data into for each unique code. Leaving this up to the lab techs has proven problematic, in that they frequent forget to rename each tab; or they enter the wrong sample ID.
On the setup tab, I've got a formula that creates each sample name to be used; and named each of the resulting names for lookup (e.g., first generated name ="Tab_01", second generated name ="Tab_02", etc. up to Tab_25), and then I've linked each with a formula in cells A1 for each of the 25 tabs in the workbook template.
The problem is... the VBA code below only works with hard text in cell A1 but not a lookup formula. Is there some way to write the VBA code so that if the lookup value does not equal "Tab_01", etc. (for each of the 25 tabs) that it will change the sheet name to the resulting tab ID name? -or possibly be written to execute a macro to paste value(s) once it's changed?
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
ActiveSheet.Name = ActiveSheet.Range("A1")
End If
End Sub
I'm not proficient with VBA code, so detailed solution example would be appreciated.
Thanks in advanced for any assistance.
Michele