VBA Excel: Delete worksheet when it has a certain name -
Text after "
My workbook, when a user wants to delete the tab for a project, they can call PRJNumber in cell T14 Put . There are several other tabs with the last 6 digits of the name of that project number (e.g., A_PRJNumber, B_PRJNumber, etc.). All PRJNumbers are 6 digits long The code given below should work, two msgboxes indicate that this is reading both in cell T14 and tab name in 6 digits, but it does not remove the tab or I do not have any errors Gives the idea?
Sub Delete_Project () Slightly completed worksheet dim PRJNumber PRJNumber = Sheet ("Program"). Range ("T14"). Price MsgBox (PRJNumber) as ActiveWorkbook. Worksheets in each Seven MsgBox (right (wks.Name, 6)) right (wks.Name, 6) = PRJNumber then wks.Delete end then the next sub-sub end then
I suspect there are some additional places in the T14 / etc.
For example:
string, strings str1 form str2 dim str1 = "123456" str2 = "123456" '## In one of these two message boxes You should not be able to tell the difference: MsgBox str1 MsgBox str2 '## But by their inputs, you can not see the same MsgBox str1 = str2
If this is the case, you can use the
trim
function which will take care of the user-error if they unknowingly enter the spaces (Often this is the result of other applications, copies etc.):PRJNumber = trim (sheets ("program"). Range ("T14"))
Comments
Post a Comment