macro for creating workbook from every worksheet + save by value defined by cell a2

Rtus10

New Member
Joined
Mar 26, 2013
Messages
11
Hi folks . Im new to the forum.. I have seen macros that create a seperate sheet & save by tab number etc, & wonder if its possible to save each sheet in a workbook as the value defined in each sheets cell A2. is there a vb macro available to do that ? if so where ?
Any help appreciated ...thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
HI James
thanks for your thoughts -I looked at that added the add in & cant get to grips with it as such even even watching the demo I get lost !
I allready have the files filtered & seperated- but saved as tab numbers, I need to (because of the quantity of the files over 1000) change the tab number of each file to the value (name) of cell a2 automatically,as it would take forever to do it manually i was looking for a macro to do that part of it for me ..thanks

Rtus10
 
Upvote 0
Hi,

Have a try with following code :

Code:
Sub RenameSheets()
Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
         ws.Name = ws.Range("A2").Value
    Next ws
End Sub

HTH
 
Upvote 0
Hi James .For some reason it fails on > ws.Name = ws.range ("A2") .Value
gives syntax error ? But when i look at the original test worksheet its done exactly what i want up to tab 18 ? rest are as original numbers , is it possible im using office home & student that causing the bother ?
 
Upvote 0
Hi,

Most probably ... there is an unexpected error in tab 19 ... could the cell A2 be empty ?

Code:
Sub RenameSheets()
Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
         [COLOR=#ff0000]On Error resume next
[/COLOR]         ws.Name = ws.Range("A2").Value
    Next ws
End Sub

HTH
 
Upvote 0
Thanks James
Ive
checked that & a2 is the first entry of data Headers on a1.. sheet 17 saved correctly - but sheet 18 has the same value (name) data in a1 as sheet19 (the names the same for all three sheets but is it a problem using / as seperator within the cell as you cant usually save using / ? etc.to explain the names are taxons (scientific names) sub divided by sub species names. using your modified code it should ignore those sheets & do the others leaving me to manually edit the others ..have i got that correct?
 
Upvote 0
Hi James running the modified macro has done the trick its left sheet 18 for me to do ..Now I can get on and edit & sort correctly ..Thankyou for your time & patience

Rtus10
 
Upvote 0

Forum statistics

Threads
1,203,486
Messages
6,055,712
Members
444,809
Latest member
mwh85

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