Extract worksheet for each item in form-Combo Box

MarkCBB

Active Member
Joined
Apr 12, 2010
Messages
497
Hi there,

I have a dashboard that I use for a survey report, all the charts and tables are linked to a form combox box, is there some code that I can use to loop though all the items of the combo box, loop until the value in A1 is = to the value in B1,

Currently I am using this:
Code:
Sub Test()

    Sheets("Sheet1").Copy
    Windows("Book1").Activate
    Range("A1").Value = Range("A1").Value + 1
    Sheets("Sheet1").Copy

End Sub

But I need to be able to save each new workbook as the value that appears in C1. i.e. the name of the item in the combo box.

I can figure out the loop part of this but I cant figure out how to do the saving of the new workbooks, can someone lend me a hand?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
just supprised myself.

Code:
Sub Macro1()

    Sheets("Sheet1").Copy
    
    ChDir "C:\Users\user\Desktop"
    ActiveWorkbook.SaveAs Filename:="C:\Users\user\Desktop\" & Range("C1").Value & ".xlsx", FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Windows("extract-Greg").Activate
    
    Range("A1").Value = Range("A1").Value + 1
    Sheets("Sheet1").Copy
    ChDir "C:\Users\user\Desktop"
    ActiveWorkbook.SaveAs Filename:="C:\Users\user\Desktop\" & Range("C1").Value & ".xlsx", FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Windows("extract-Greg").Activate
    
       Range("A1").Value = Range("A1").Value + 1
    Sheets("Sheet1").Copy
    ChDir "C:\Users\user\Desktop"
    ActiveWorkbook.SaveAs Filename:="C:\Users\user\Desktop\" & Range("C1").Value & ".xlsx", FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Windows("extract-Greg").Activate
       Range("A1").Value = Range("A1").Value + 1
    Sheets("Sheet1").Copy
    ChDir "C:\Users\user\Desktop"
    ActiveWorkbook.SaveAs Filename:="C:\Users\user\Desktop\" & Range("C1").Value & ".xlsx", FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Windows("extract-Greg").Activate
    Range("A1").Value = 1
    

End Sub
 
Upvote 0
:)

Code:
Sub Test()
    Range("A1").Value = 0
    Do
    Range("A1").Value = Range("A1").Value + 1
    Sheets("Sheet1").Copy
    ChDir "C:\Users\user\Desktop"
    ActiveWorkbook.SaveAs Filename:="C:\Users\user\Desktop\" & Range("C1").Value & ".xlsx", FileFormat _
        :=xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWindow.Close
    Windows("extract-Greg").Activate
    Loop Until Range("A1").Value = Range("B1").Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,147
Members
452,891
Latest member
JUSTOUTOFMYREACH

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