excel vba sheet name

BORUCH

Well-known Member
Joined
Mar 1, 2016
Messages
548
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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:
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,136
Members
453,021
Latest member
Justyna P

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