Renaming workbook in VBA & Sum function?

ajmckenna

Board Regular
Joined
Oct 7, 2002
Messages
145
I want to add a section to my macro to rename the worksheets created to the text in a particular cell (i.e. "2000 P&L" which is in cell A2 any ideas?

Also in using a 3d sum function to sum up multiple sheets, my workbook names may change is it possible to enter the formula using worksheet index e.g

current formula

=SUM(Sheet1:Sheet2!B7)to something like

=SUM(Worksheet(1):Worksheet(worksheet.count-1)!B7) this formula obviously doesn't word

I want it to sum the same cell in the first worksheet to the next to last worksheet
any ideas?

thanks all
AJ
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
This uses a hard coded save path, it could be made to pull the save-as box to select a folder if you need to. JSW

Sub SaveByCell()
Dim sFileName As String
'Cell A1 has the new file name.
sFileName = Sheets("Sheet1").Range("A1")

'If Cell A1 is Blank do not save.
If sFileName = "" Then Exit Sub

'The Drive:Path & the file name in cell A1.
ThisWorkbook.SaveAs "C:MyFilesJSWExcelData" & sFileName
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

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