Option Explicit
Sub zip_it()
'I have created a MACRO that copies data from "sheet2 A1" and pastes
'in in sheet1 range - "gunner". This causes changes in sheet3.
'The MACRO copies the info from sheet3 into a batch file and then
'it runs the batch file. The batch file goes to the folder named
'and creates a ZIP file.
'"Sheet2, column A" is a list of file folders that need to be compressed.
'It is a large and changing list - ergo the MACRO.
'I would like the MACRO to go through the process that I have outlined,
'then go back to sheet2, take the new entry and start the process over
'again, until column A is empty.
'=========================================================================
Dim ListOfFolders As Range, _
Rng As Range, _
Foldername As Range, _
TestCell As Range, _
BatName As String, _
SHEET1 As Worksheet, _
SHEET2 As Worksheet, _
SHEET3 As Worksheet
BatName = "d:/testit.bat"
Set SHEET1 = Worksheets("Sheet1")
Set SHEET2 = Worksheets("Sheet2")
Set SHEET3 = Worksheets("Sheet3")
Set ListOfFolders = SHEET2.Range("A1:A" & SHEET2.Cells(Rows.Count, "A").End(xlUp).Row)
Set Rng = SHEET3.Range("A1:A" & SHEET3.Cells(Rows.Count, "A").End(xlUp).Row)
For Each Foldername In ListOfFolders
SHEET1.Range("gunner").ClearContents
Foldername.Copy Range("gunner")
Open BatName For Output As #1
For Each TestCell In Rng
Print #1, TestCell.Text
Print #1, TestCell.Offset(0, 1).Text
Print #1,
Next TestCell
Close #1
Call Shell(BatName, vbNormalFocus)
Next Foldername
End Sub
Bookmarks