Looping a macro through all visible sheets?

GlennJ

Board Regular
Joined
Mar 26, 2018
Messages
63
Office Version
  1. 2016
Platform
  1. Windows
I have a macro that does exactly what I need. I just need it to do the same thing to all sheets. Any help would be appreciated.

VBA Code:
Sub Name_Sheet()

If Range("I14").Value = "" Then
    'Do nothing
Else
    ActiveSheet.Name = Range("I14").Value
End If

End Sub
 
What happens if you remove the Iferror?
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
But do you get anything in the cell if you remove the iferror?
 
Upvote 0
Yes, the exact same thing. I don't think it would make any difference which way it is now. This file has been changed many times as head office is trying to do what they can to keep revenue flowing during Covid. It probably made a difference on the version from a year ago. This is the last thing I need to get solved.
Can the error checker be programed to just click OK for each msg box? It would do what I need
 
Upvote 0
They're closing the building now (Canada). I'll check back tomorrow.
Thanks again for all your help
 
Upvote 0
When the message box appears what does it show? Do you have the current sheet name & the new sheet name?
 
Upvote 0
In that case the cell has a space or some other "hidden" character & so is not ""
 
Upvote 0
Solution
In that case the cell has a space or some other "hidden" character & so is not ""
I found it. The first and last name come to me in two different cells. To combine them into one, I was using =T3&" "&U3 and this was leaving a space in the cell. I found that if I use =TEXTJOIN(" ",,T3,U3), the space doesn't get in the way. Now your original Marco runs perfect.
I would never have found that without you narrowing it down for me.
Big thanks FLUFF for all your help and patience. I wish I could do more that click a Solved button.

Cheers
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,873
Members
449,056
Latest member
ruhulaminappu

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