1st part of code for tab name problem

DThib

Active Member
Joined
Mar 19, 2010
Messages
464
Office Version
  1. 365
Platform
  1. Windows
Hello,

My code will run the rest of the macro, but I am having trouble pulling the tab name to be changed before the save and export.

My tab name will have elements from String names run and identified in other code running in this workbook. I am trying to pull the name in total with the first macro.
The second macro is my attempt at renaming the tab before save and export as CSV of this worksheet.
I keep getting an error 9. Subscript out of range on the sheets("ProName") in the second macro.

Code:
Sub Tabname_Pro()

   Dim ProName As String
   Dim Filenumber, Study As String
    ProName = Study & "_Run" & Filenumber & "_Pro"
'   Study & "_Run" & Filenumber & "_Pro"
    With sheets("XXX_Pro_Run")
    '.Value = ProName
    .Name = ProName
    End With
End sub

Code:
Sub CSVLIMS()

     Call Tabname_Pro
         Dim ProName As String
         
            Application.Left = 1466.5
            Application.Top = 7.75
            
            sheets("ProName").Select
            Range("A1:K42").Select
            Cells.Select
            Selection.Copy
            Workbooks.Add
            ActiveSheet.Paste
            Application.CutCopyMode = False
            ChDir "\\server\Templates"
            ActiveWorkbook.SaveAs Filename:= _
                "\\server\Templates\ProName.csv" _
                , FileFormat:=xlCSV, CreateBackup:=False
        
            ActiveWindow.Close
            sheets("RUN-Setup").Select
            Range("A2").Select
End Sub
 
You haven't answered the 2nd question
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Sorry, forgot that.
They are in coding for userform that calls code to find and copy the selected files.
I can move the statements to a module outside of the userform, but will it be seen by code if that module is not invoked?
 
Last edited:
Upvote 0
Thank you!

That did the trick!

I appreciate the help.
I went back through all my modules and cleaned out more DIM statements for the Public declared names.
 
Upvote 0
glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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