excel vba sheet name

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
273
Hi

i would like a vba that does the flowing

if my seventh character from my sheet name begins with a "4" then delete row 12 from the sheet if not continue to the rest of the code

Thanks
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,747
Office Version
365, 2010
Platform
Windows, Mobile
my sheet name
Which sheet? the activesheet?

my seventh character from my sheet name begins with a "4"
Not understanding the use of "begins with", do you mean if the seventh character is a 4?

if not continue to the rest of the code
What other code?
 
Last edited:

BORUCH

Active Member
Joined
Mar 1, 2016
Messages
273
Which sheet? the activesheet?


Not understanding the use of "begins with", do you mean if the seventh character is a 4?


What other code?
Yes it's the active sheet

Yes I mean if the seventh character is a 4

I would like to put this code in the beginning of a module which has code for doing other things
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,747
Office Version
365, 2010
Platform
Windows, Mobile
Maybe...

Code:
Sub Delete12()
    If Mid(ActiveSheet.Name, 7, 1) = 4 Then
        ActiveSheet.Rows(12).Delete 'you could do away with the activesheet and just have Rows(12).Delete
    Else
        MsgBox "Rest of your code here"
    End If
End Sub
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,747
Office Version
365, 2010
Platform
Windows, Mobile
Or depending if you want to code to run anyway if the row 12 is deleted then

Code:
Sub Delete12()
    If Mid(ActiveSheet.Name, 7, 1) = 4 Then ActiveSheet.Rows(12).Delete 'you could do away with the activesheet and just have Rows(12).Delete
  ' Rest of your code here
End Sub
 

Forum statistics

Threads
1,085,542
Messages
5,384,323
Members
401,887
Latest member
Somesh

Some videos you may like

This Week's Hot Topics

Top