VB - Queued data into separate workbook

achtoju

New Member
Joined
May 20, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I'm working on VB file that determine specific content based on cell value, queue it, update in separate tabs copy&save those tabs into new workbook. Workbook name is define by cell and for every data individual. Everyting works for me perfectly correct, but new woorkbooks (even when they have different names) have all the same data inside (assigned to last value from queue). Data in the tabs is based on VLOOKUP formula [and connected to cell value in Sheets("Sheet1").Cells(1, 5) = Sheets("Sheet1").Cells(i, 1)]. Any ideas how to force VB so it will copy proper data to proper workbooks - not only last in queue? The code :
VBA Code:
ub Auto()
 Dim InitFileName As String, fileSaveName As String
 Dim i As Integer
 
 For i = 7 To 8
 Sheets("Sheet1").Cells(1, 5) = Sheets("Sheet1").Cells(i, 1)

fileSaveName = "FILES DESTINATION FOLDER\test " & Sheets("Sheet1").Cells(1, 16) & ".xlsx"
Worksheets(Array("1", "2", "3")).Copy
Set wbNew = ActiveWorkbook
With wbNew
    .SaveAs fileSaveName
    .Close
   
End With
Next i
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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