TommyNewtoExcel
New Member
- Joined
- Nov 4, 2019
- Messages
- 6
All,
I developed a process for a small data set and it now needs to scale to cover large data grabs from outside of the workbook (in closed workbooks on a drive) then have the macro deposit the output into new workbooks in a different file folder (currently my code drops the new workbooks into the same folder) . I originally copied the forms into the workbook when I had to do 3 at a time but now it will be used to generate hundreds at a time.
The example code below is from the workbook that had all data in sheets inside the workbook but will now need to grab the sheets to be used from other closed workbooks:
i don't know how to adjust these parameters to meet my needs I think its just a range issue potentially. The new file I need to use has the following name and drive directory:
New file to populate with info from the workbook with the macro in it. C:\Users\thocoult\Desktop\Newst macro\Source docs structure\Mechanical\Master
Once populated need to be saved in the following location as a newly named file: C:\Users\thocoult\Desktop\Newst macro\Source docs structure\Mechanical\RIF
I developed a process for a small data set and it now needs to scale to cover large data grabs from outside of the workbook (in closed workbooks on a drive) then have the macro deposit the output into new workbooks in a different file folder (currently my code drops the new workbooks into the same folder) . I originally copied the forms into the workbook when I had to do 3 at a time but now it will be used to generate hundreds at a time.
The example code below is from the workbook that had all data in sheets inside the workbook but will now need to grab the sheets to be used from other closed workbooks:
i don't know how to adjust these parameters to meet my needs I think its just a range issue potentially. The new file I need to use has the following name and drive directory:
New file to populate with info from the workbook with the macro in it. C:\Users\thocoult\Desktop\Newst macro\Source docs structure\Mechanical\Master
Once populated need to be saved in the following location as a newly named file: C:\Users\thocoult\Desktop\Newst macro\Source docs structure\Mechanical\RIF
Code:
Public Sub GenerateRIF()
Dim i As Integer
Dim x As Integer
Dim FilePath As String
Dim FullFileName As String
Dim wbkCurrent As Workbook
Dim RIFManufacturer As String
Dim RIFType As String
Dim RIFCapacity As String
Dim RIFVoltage As String
Dim RIFEquipmentTag As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
i = 1
x = Application.WorksheetFunction.CountA(Range("B:B"))
'Update to your file path"
FilePath = "C:\Users\thocoult\Desktop\Newst macro\"
Set wbkCurrent = ActiveWorkbook
Application.Goto Reference:="AHUData"
Range("AHUData").Cells(i, 2).Select
For i = 1 To x
Application.Goto Reference:="AHUData"
RIFManufacturer = Range("AHUData").Cells(i, 4).Value
RIFType = Range("AHUData").Cells(i, 7).Value
RIFCapacity = Range("AHUData").Cells(i, 7).Value
RIFVoltage = Range("AHUData").Cells(i, 29).Value
RIFEquipmentTag = Range("AHUData").Cells(i, 2).Value
If Left(Range("AHUData").Cells(i, 2).Value, 3) = "AHU" Then
'Manufacturer
Application.Goto Reference:="RIFManufacturer"
Range("RIFManufacturer").Value = RIFManufacturer
'Type
Application.Goto Reference:="RIFType"
Range("RIFType").Value = RIFType
'Capacity
Application.Goto Reference:="RIFCapacity"
Range("RIFCapacity").Value = RIFCapacity
'Volts/Phase/Hertz
Application.Goto Reference:="RIFVoltage"
Range("RIFVoltage").Value = RIFVoltage
'EquipmentTag
Application.Goto Reference:="RIFEquipmentTag"
Range("RIFEquipmentTag").Value = RIFEquipmentTag
'Hard code building id in all of the forms
Range("buildingFINID") = "IAD65"
FullFileName = FilePath & "RIF_" & Range("AHUData").Cells(i, 2).Value & ".xlsx"
' If i = 1 Then
Worksheets("RIF").Copy
ActiveWorkbook.SaveAs Filename:=FullFileName, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
wbkCurrent.Activate
End If
Next i
'turning back on auto calculations
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
[code]