Looping a macro through all visible sheets?

GlennJ

Board Regular
Joined
Mar 26, 2018
Messages
59
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
58,153
Office Version
  1. 365
Platform
  1. Windows
What happens if you remove the Iferror?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
58,153
Office Version
  1. 365
Platform
  1. Windows
But do you get anything in the cell if you remove the iferror?
 

GlennJ

Board Regular
Joined
Mar 26, 2018
Messages
59
Office Version
  1. 2016
Platform
  1. Windows
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
 

GlennJ

Board Regular
Joined
Mar 26, 2018
Messages
59
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

They're closing the building now (Canada). I'll check back tomorrow.
Thanks again for all your help
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
58,153
Office Version
  1. 365
Platform
  1. Windows
When the message box appears what does it show? Do you have the current sheet name & the new sheet name?
 

GlennJ

Board Regular
Joined
Mar 26, 2018
Messages
59
Office Version
  1. 2016
Platform
  1. Windows

ADVERTISEMENT

When the message box appears what does it show? Do you have the current sheet name & the new sheet name?
Just the current sheet name.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
58,153
Office Version
  1. 365
Platform
  1. Windows
In that case the cell has a space or some other "hidden" character & so is not ""
 
Solution

GlennJ

Board Regular
Joined
Mar 26, 2018
Messages
59
Office Version
  1. 2016
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
58,153
Office Version
  1. 365
Platform
  1. Windows
Glad you sorted it & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,685
Messages
5,654,748
Members
418,149
Latest member
amamiche67

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
Top