Excel Vba Save Single sheet to new Workbook using variable in a cell

ChinHaou

New Member
Joined
Apr 3, 2013
Messages
2
Good Day Ladies And Gents.

I need to save a worksheet out of a workbook depending on the data entered into cell G24 (for example)
The reason is that I process the Jobcards for my company as well as the Manufacturing Certificates for each job.
Each of these files have a certain set of documents that go with it (which I can save already into a new sheet).
BUT, each type of product has a certain ISO Document that goes with it.

example :
Product A would get ISO doc 1234
Product B would get ISO doc 1235

This is what i have:
Workbook "Alpha"
sheets : "Front_Page", "Job_Card", "Collection", "GB_Build", "Regdoc_Grn,"

(then here come the variable sheets):
sheets : "123", "124", "125", "126", "127"

How my macro works is as follows :

Application.ScreenUpdating = False
'Dim sNatisDoc As String (Coding I'm struggling with)
'sNatisDoc = Range("C24").Value (Coding I'm struggling with)

Sheets(Array("Front_Page", "Job_Card", "Collection", "GB_Build", "Regdoc_Grn", "Regdoc_Bl")).Select
Sheets(Array("Front_Page", "Job_Card", "Collection", "GB_Build", "Regdoc_Grn", "Regdoc_Bl")).Copy
(the above needs to change to something like:)
'Sheets(Array("Front_Page", "Job_Card", "Collection", "GB_Build", "Regdoc_Grn", "Regdoc_Bl", "sNatisDoc")).Select

'Sheets(Array("Front_Page", "Job_Card", "Collection", "GB_Build", "Regdoc_Grn", "Regdoc_Bl", "sNatisDoc")).Copy
ThisFile = Range("H3").Value
ActiveSheet.SaveAs Filename:="path\" & ThisFile & ".xls"
Application.ScreenUpdating = True
ActiveWorkbook.Close
Range("G3").Value = 1 + Range("G3").Value

As you can see that I have the array sorted out.
What I'm struggling with is defining what sheet to save according to the data entered in "C24"

If you masters could please please help me with this my life would become a million times easier.

Regards
Chin
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

ChrisM

Well-known Member
Joined
Jun 11, 2002
Messages
2,129
It looks like what you have should work if you just remove the quotes around sNatisDoc in the two array lines. It should be:

Sheets(Array("Front_Page", "Job_Card", "Collection", "GB_Build", "Regdoc_Grn", "Regdoc_Bl", sNatisDoc)).Select
 
Upvote 0

ChinHaou

New Member
Joined
Apr 3, 2013
Messages
2
ChrisM,

I thank you ever so dearly.
It would appear that my google degree in vba can only take me that far.
BUt the Coding works 100% now.

Thanks
 
Upvote 0

Forum statistics

Threads
1,195,674
Messages
6,011,096
Members
441,582
Latest member
Topkapi

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