left or right in tab

mrinal saha

Board Regular
Joined
Jan 20, 2009
Messages
229
Hi Folks,

I have a sheet with name as below: I want to set a condition if the sheet name is RCD (Non-Recallable). How to identify in vba what is the right part of the tab name.

05252011 RCD (Non-Recallable)

Thanxxxx,
Mrinal
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
For what you asked, I think you may be looking for this...
Code:
If Right(ActiveSheet.Name, 20) = "RCD (Non-Recallable)" Then
    MsgBox "The ActiveSheet's Name ends with ""RCD (Non-Recallable)"""
End If
 
Upvote 0
Try this

Code:
Sub SheetNameCheck()
    Dim strSheetName        As String
    
    strSheetName = ActiveSheet.Name
    
    If InStr(strSheetName, "RCD (Non-Recallable") Then
        MsgBox "Name Found"
    Else
    
    End If
End Sub
 
Upvote 0
Try this

Code:
Sub SheetNameCheck()
    Dim strSheetName        As String
 
    strSheetName = ActiveSheet.Name
 
    If InStr(strSheetName, "RCD (Non-Recallable") Then
        MsgBox "Name Found"
    Else
 
    End If
End Sub
That won't restrict itself to finding the text on the right side of the name... it will report the name found even it the searched for text is in the middle with other text surrounding it.
 
Upvote 0
Well I want the text after the date. But I can't give the precise number of characters beacuse it would vary tab to tab. So provide me with a dynamic solution

thanks
Mrinal
 
Upvote 0
Well I want the text after the date. But I can't give the precise number of characters beacuse it would vary tab to tab. So provide me with a dynamic solution
Okay, then you want all the text after the first space...
Code:
NameAfterDate = Split(ActiveSheet.Name, " ", 2)(1)

EDIT
Here is my originally posted code modified to use the above (in case that is actually what you are looking for)...
Code:
If Split(ActiveSheet.Name, " ", 2)(1) = "RCD (Non-Recallable)" Then
    MsgBox "The ActiveSheet's Name ends with ""RCD (Non-Recallable)"""
End If
 
Last edited:
Upvote 0
Does this line looks ok..........because it isn't working

If Sheets(l).Name = Sheets("Rough").Cells(i, 1).Value And Split(Sheets(l).Name, " ", 2)(1) = "Sale" Or _
Split(Sheets(l).Name, " ", 2)(1) = "RCD (Non-Recallable)" _
Or Split(Sheets(l).Name, " ", 2)(1) = "PDR(Non Recallable)" Then
deal = Sheets("Rough").Cells(i, 4).Value
 
Upvote 0
It is usually a good idea to tell us more than "it isn't working" so we have an idea where to concentrate our efforts. What exactly do you mean by "isn't working"... are you getting an error message and, if so, what is it? Also, what is L equal to (that is the argument you have for your Sheets property call and how does that relate to the "i" you have in your Cells property call... are you in a double loop of some sort? Maybe if you post more of your code, it might help.
 
Upvote 0

Forum statistics

Threads
1,224,612
Messages
6,179,890
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top