Sunday, 18 September 2016

Change Macro To change the name of one sheet [Anwsered]

Change Macro To change the name of one sheet

Hi I got the following macro from this community (thank you again), it adds the word "old" to all the worksheet names of all the files in a folder.  I want to change it slightly so that only the worksheet with the name "Week 41" will be changed to "Week41
Ver1", and if the Workbook does not contain such a worksheet it must just close without saving.

This is the Macro

Sub RenameSheets()
    Dim strFolder As String
    Dim strFile As String
    Dim wbk As Workbook
    Dim i As Long
    With Application.FileDialog(4) ' msoFileDialogFolderPicker
        ' Show dialog
        If .Show Then
            ' Assign selected folder to variable
            strFolder = .SelectedItems(1)
        Else
            Beep
            Exit Sub
        End If
    End With
    ' Append \ if necessary
    If Right(strFolder, 1) <> "\" Then
        strFolder = strFolder & "\"
    End If
    On Error GoTo ErrHandler
    ' Turn off screen updating and event handling
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    ' Get first file name in folder
    strFile = Dir(strFolder & "*.xls*")
    ' Loop
    Do While strFile <> ""
        ' Open workbook
        Set wbk = Workbooks.Open(Filename:=strFolder & strFile)
        ' Loop through sheets except first one
        For i = 2 To wbk.Worksheets.Count
            With wbk.Worksheets(i)
                ' Append " Old" to sheet name
                .Name = .Name & " Old"
            End With
        Next i
        ' Close and save workbook
        wbk.Close SaveChanges:=True
        ' Get next file name
        strFile = Dir
    Loop
ExitHandler:
    ' Turn on screen updating and event handling
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Exit Sub
ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
End Sub

Thank You for the help

Es

Solutions to the Problem Change Macro To change the name of one sheet

Download SmartPCFixer for Free Now

How to Avoid Downloading Malware

Where are you getting the download?

There are malicious people who download valid copies of a popular download, modify the file with malicious software, and then upload the file with the same name. Make sure you are downloading from the developer's web page or a reputable company.


Cancel or deny any automatic download

Some sites may automatically try start a download or give the appearance that something needs to be installed or updated before the site or video can be seen. Never accept or install anything from any site unless you know what is downloading.

Avoid advertisements on download pages

To help make money and pay for the bandwidth costs of supplying free the software, the final download page may have ads. Watch out for anything that looks like advertisements on the download page. Many advertisers try to trick viewers into clicking an ad with phrases like "Download Now", "Start Download", or "Continue" and that ad may open a separate download.

Another Safe way to Repair the Problem: Change Macro To change the name of one sheet:

How to Fix Change Macro To change the name of one sheet with SmartPCFixer?

1. Click the button to download Error Fixer . Install it on your system.  Run it, and it will scan your computer. The junk files will be shown in the scan result.

2. After the scan is finished, you can see the errors and problems which need to be fixed.

3. The Fixing part is done, the speed of your computer will be much higher than before and the errors have been fixed.


Related: How Can You Update & Download Toshiba Satellite 5105-S501 Intel PRO 10/100 Driver v.8.0.43.0,How to Update & Download Toshiba Satellite C655D-S5139 BookPlace v.2.2.7530 driver,Method to Update & Download Toshiba Satellite L655-S5073 Realtek Wireless LAN Driver v.2.00.0011,Method to Update & Download Toshiba Satellite L840-ST2N01 Sleep Utility v.1.4.0022.000104 driver,Best Way to Update & Download Toshiba Satellite Pro S300-EZ2502 Extended Tiles for Windows Mobility Center v.1.01 driver,Best Way to Download NVidia GeForce 6100 VGA Driver v.304.51 Certified,How Can You Update & Download NVidia GeForce 9300/nForce 730i VGA Driver v.310.19 Certified,Method to Download NVidia GeForce GT 330M Driver v.340.65,How Can I Update & Download NVidia GeForce GTX 590 Driver v.280.26 WHQL,Method to Download NVidia Tesla C2050 Driver v.319.17,Way to Download RealTek RTL8100C(L) Driver v.5.01,Way to Download RealTek RTL8100E Drivers v.694,Way to Update & Download RealTek RTL8101L Auto Installation Program v.6.110 driver,Method to Update & Download RealTek RTL8111G PXE and RPL ROM code v.2.58 driver,How to Update & Download RealTek RTL8411B(N) Driver v.10.003,Best Way to Update & Download ASUS A53SV nVidia Graphics Driver v.8.17.12.6686,Method to Herunterladen ASUS K75VJ Intel Rapid Storage Technology Treiber v.11.6.0.1030,How Can You Update & Download ASUS CG8580 Intel Chipset Driver v.9.3.0.1019,Method to Update & Download ASUS K41VD Intel INF Update Driver v.9.1.1.1015,Way to Update & Download ASUS Pro70T NB Probe v.3.0.0026 driver,Can't Download PP Templates Automatically To Windows 7 W/IE 8,Can't Change Drive Letter - Vista,Can't Change Homegroup Sharing Permission,Can't Connect XP Shared Printer To Win7 Except As A Local Printer.__,Can You Connect The LAN Adapter For Wii On Your Windows 7 Laptop?
Read More: How to Resolve - check that Internet exployer iis default brpwser?,CD/DVD drive not working, won't open CD after inserted. Tech Support,Troubleshooting:chkdsk question,How to Fix Error - Cell content and format?,Troubleshooter of Error: cant connect to http:\/\/zone.msn.com\/en\/hearts\/zpadefault.htm,Can't access c drive to open programs.,Can you use just one hard drive to store a backup disk image and restore for multiple computers?,can not install Mcafee due to Java script error,,Can Word's track changes comments print in the outside border?,cannot install old software program because computer missing indeo codec driver

No comments:

Post a comment