Stuck at WorkBooks.Open, Same Excel file is working fine for others - excel

I am really sorry for writing such a lengthy question but I wanted to explain the issue in detail. I searched regarding my problem here but couldn't find a solution that works, so posting my issue here.
I have an Excel file which contains macros & takes daily Open Interest data from CME (Chicago Mercantile Exchange) Group, USA; and updates an interal database which then updates the line charts. This file stopped working for me now, I got it coded by a brilliant Excel VBA programmer, which i am not able to find now to fix the issue.
https://www.cmegroup.com/market-data/volume-open-interest/metals-volume.html
This website updates the data twice a day, Preliminary & Final. So macro has functions to check final data first, if its found, it updates the data otherwise it looks for preliminary data & udate it. This file has a sheet called "Main" where we write the date in a cell & has two buttons (two macros, one udpates the data for individual date & second updates the data if data from multiple date needs updating). It has a sheet called "Links" which contains the URL in parts to download desired workbook/sheets in to file, then it copies the the specific data into separate data sheets inside the file for each instrument, which is used to make/update the Open Interest line charts for each individual financial instrument.
These macros are working fine for other friends who are using different windows & excel versions but they stopped working in my computers (yes, in three latptops. Couple of laptops had Windows 10 & Excel 2016, other laptop has Windows 11 & Excel 2021). STRANGELY & ACCIDENTLY i found a solution that when i run the macro by pressing button from sheet "Main" & it gets stuck, I press ESC button few times, macros runs & update the data/line charts perfectly. BUT they don't work for me noramlly as they are working for others in exactly same file. Macros are unblocked & fully enabled from Trust Center.
On pressing the button from sheet "Main", macro starts & file goes to unlimited processing. I am copying the full code here.
Sub download_data2()
Dim lastdate, report_date As Date
Application.ScreenUpdating = False
Sheets("Main").Cells(1, 1).Value = 1
'getting todays links
report_date = Sheets("Main").Cells(1, 3).Value
extr_date = Format(Year(report_date), "00") & Format(Month(report_date), "00") & Format(Day(report_date), "00")
Sheets("Links").Cells(2, 1).Value = extr_date
'links for final data
link_metal = Sheets("Links").Cells(1, 1).Value & extr_date & Sheets("Links").Cells(3, 1).Value & Sheets("Links").Cells(5, 1).Value
link_fx = Sheets("Links").Cells(1, 1).Value & extr_date & Sheets("Links").Cells(4, 1).Value & Sheets("Links").Cells(5, 1).Value
link_oil = Sheets("Links").Cells(1, 1).Value & extr_date & Sheets("Links").Cells(9, 1).Value & Sheets("Links").Cells(5, 1).Value
link_irv = Sheets("Links").Cells(1, 1).Value & extr_date & Sheets("Links").Cells(10, 1).Value & Sheets("Links").Cells(5, 1).Value
link_eqvol = Sheets("Links").Cells(1, 1).Value & extr_date & Sheets("Links").Cells(11, 1).Value & Sheets("Links").Cells(5, 1).Value
wb_name = ActiveWorkbook.Name
Workbooks(wb_name).Sheets("Metals").Range("A1:X5000").Clear
Workbooks(wb_name).Sheets("Metals").Shapes.SelectAll
Selection.Delete
Workbooks(wb_name).Sheets("FX").Range("A1:X5000").Clear
Workbooks(wb_name).Sheets("FX").Shapes.SelectAll
Selection.Delete
Workbooks(wb_name).Sheets("Energy").Range("A1:X5000").Clear
Workbooks(wb_name).Sheets("Energy").Shapes.SelectAll
Selection.Delete
Workbooks(wb_name).Sheets("Interest Rate Volume").Range("A1:X5000").Clear
Workbooks(wb_name).Sheets("Interest Rate Volume").Shapes.SelectAll
Selection.Delete
Workbooks(wb_name).Sheets("Equity Volume").Range("A1:X5000").Clear
Workbooks(wb_name).Sheets("Equity Volume").Shapes.SelectAll
Selection.Delete
'download final data
Application.DisplayAlerts = False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_metal
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Metals").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_fx
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("FX").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_oil
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Energy").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.00011)
Workbooks.Open link_irv
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Interest Rate Volume").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_eqvol
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Equity Volume").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
Application.DisplayAlerts = True
'check if there is final data
If Sheets("Metals").Cells(7, 1).Value = "" Then
'download preliminary data
link_metal = Replace(link_metal, "reportType=F", "reportType=P")
link_fx = Replace(link_fx, "reportType=F", "reportType=P")
link_oil = Replace(link_oil, "reportType=F", "reportType=P")
link_irv = Replace(link_irv, "reportType=F", "reportType=P")
link_eqvol = Replace(link_eqvol, "reportType=F", "reportType=P")
Application.DisplayAlerts = False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_metal
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets(1).Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Metals").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_fx
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("FX").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_oil
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Energy").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_irv
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Interest Rate Volume").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
'Application.Wait (Now + 0.000011)
Workbooks.Open link_eqvol
last_row = Sheets("VOI Totals Report").Cells(5, 1).End(xlDown).Row
last_column = Sheets("VOI Totals Report").Cells(5, 1).End(xlToRight).Column
last_column = Split(Cells(, last_column).Address, "$")(1)
Sheets("VOI Totals Report").Range("A5:" & last_column & last_row).Copy Workbooks(wb_name).Sheets("Equity Volume").Range("A5:" & last_column & last_row)
'Workbooks("voiProductsViewExport").Close False
ActiveWorkbook.Close False
Application.DisplayAlerts = True
End If
'check if no data at all for this date
If Sheets("Metals").Cells(7, 1).Value = "" Then
Exit Sub
End If
'updating the tabs
'Gold
For T = 7 To Sheets("Metals").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Metals").Cells(T, 1).Value Like "Gold Futures" Then
met_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_met("Gold", "Gold OI Chart", met_pos, report_date)
met_pos = Empty
'Silver
For T = 7 To Sheets("Metals").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Metals").Cells(T, 1).Value Like "Silver" & "*" & "Future*" Then
met_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_met("Silver", "Silver OI Chart", met_pos, report_date)
met_pos = Empty
'Copper
For T = 7 To Sheets("Metals").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Metals").Cells(T, 1).Value Like "Copper Future*" Then
met_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_met("Copper", "Copper OI Chart", met_pos, report_date)
met_pos = Empty
'Iron Ore
For T = 7 To Sheets("Metals").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Metals").Cells(T, 1).Value Like "Iron Ore" & "*" & "(TSI) Future*" Then
met_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_met("Iron Ore", "Iron Ore OI Chart", met_pos, report_date)
met_pos = Empty
'Palladium
For T = 7 To Sheets("Metals").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Metals").Cells(T, 1).Value Like "Palladium Future*" Then
met_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_met("Palladium", "Palladium OI Chart", met_pos, report_date)
met_pos = Empty
'Platinum
For T = 7 To Sheets("Metals").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Metals").Cells(T, 1).Value Like "Platinum Future*" Then
met_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_met("Platinum", "Platinum OI Chart", met_pos, report_date)
met_pos = Empty
'updating oil
For T = 7 To Sheets("Energy").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Energy").Cells(T, 1).Value Like "Crude Oil Futures" Then
met_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_energy("Oil", "Oil OI Chart", met_pos, report_date)
met_pos = Empty
'Henry Hub Natural Gas
For T = 7 To Sheets("Energy").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Energy").Cells(T, 1).Value Like "Henry Hub Natural Gas Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_energy("Henry Hub Natural Gas", "Henry Hub Natural Gas Chart", fx_pos, report_date)
fx_pos = Empty
'EUR
For T = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("FX").Cells(T, 1).Value Like "Euro FX Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_fx("EUR", "EUR Chart", fx_pos, report_date)
fx_pos = Empty
'GBP
For T = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("FX").Cells(T, 1).Value Like "British Pound Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_fx("GBP", "GBP Chart", fx_pos, report_date)
fx_pos = Empty
'JPY
For T = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("FX").Cells(T, 1).Value Like "Japanese Yen Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_fx("JPY", "JPY Chart", fx_pos, report_date)
fx_pos = Empty
'CHF
For T = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("FX").Cells(T, 1).Value Like "Swiss Franc Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_fx("CHF", "CHF Chart", fx_pos, report_date)
fx_pos = Empty
'AUD
For T = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("FX").Cells(T, 1).Value Like "Australian Dollar Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_fx("AUD", "AUD Chart", fx_pos, report_date)
fx_pos = Empty
'NZD
For T = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("FX").Cells(T, 1).Value Like "New Zealand Dollar Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_fx("NZD", "NZD Chart", fx_pos, report_date)
fx_pos = Empty
'CAD
For T = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("FX").Cells(T, 1).Value Like "Canadian Dollar Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_fx("CAD", "CAD Chart", fx_pos, report_date)
fx_pos = Empty
'10-Year T-Note Future
For T = 7 To Sheets("Interest Rate Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Interest Rate Volume").Cells(T, 1).Value Like "10-Year T-Note Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_irv("10Y TNF", "10Y TNF Chart", fx_pos, report_date)
fx_pos = Empty
'2-Year T-Note Future
For T = 7 To Sheets("Interest Rate Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Interest Rate Volume").Cells(T, 1).Value Like "2-Year T-Note Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_irv("2Y TNF", "2Y TNF Chart", fx_pos, report_date)
fx_pos = Empty
'5-Year T-Note Future
For T = 7 To Sheets("Interest Rate Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Interest Rate Volume").Cells(T, 1).Value Like "5-Year T-Note Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_irv("5Y TNF", "5Y TNF Chart", fx_pos, report_date)
fx_pos = Empty
'Eurodollar Future
For T = 7 To Sheets("Interest Rate Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Interest Rate Volume").Cells(T, 1).Value Like "Eurodollar Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_irv("EURODOLLAR", "EURODOLLAR Chart", fx_pos, report_date)
fx_pos = Empty
'U.S. Treasury Bond Future
For T = 7 To Sheets("Interest Rate Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Interest Rate Volume").Cells(T, 1).Value Like "U.S. Treasury Bond Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_irv("US Treas Bond", "US Treas Bond Chart", fx_pos, report_date)
fx_pos = Empty
'Ultra U.S. Treasury Bond Future
For T = 7 To Sheets("Interest Rate Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Interest Rate Volume").Cells(T, 1).Value Like "Ultra U.S. Treasury Bond Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_irv("Ultra US Treas Bond", "Ultra US Treas Bond Chart", fx_pos, report_date)
fx_pos = Empty
'E-Mini Russell 2000 Index Future
For T = 7 To Sheets("Equity Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Equity Volume").Cells(T, 1).Value Like "E-mini Russell 2000 Index Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_eqvol("E-Mini Rus2000 Index", "E-Mini Rus2000 Index Chart", fx_pos, report_date)
fx_pos = Empty
'E-Mini Dow ($5) Future
For T = 7 To Sheets("Equity Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Equity Volume").Cells(T, 1).Value Like "E-mini Dow ($5) Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_eqvol("E-mini Dow 5", "E-mini Dow 5 Chart", fx_pos, report_date)
fx_pos = Empty
'E-Mini Nasdaq-100 Futures
For T = 7 To Sheets("Equity Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Equity Volume").Cells(T, 1).Value Like "E-mini Nasdaq-100 Futures*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_eqvol("E-mini Nasdaq 100", "E-mini Nasdaq 100 Chart", fx_pos, report_date)
fx_pos = Empty
'E-mini S&P 500 Future
For T = 7 To Sheets("Equity Volume").Cells(Rows.Count, 1).End(xlUp).Row
If Sheets("Equity Volume").Cells(T, 1).Value Like "E-mini S&P 500 Future*" Then
fx_pos = T
Exit For
End If
Next T
Call Tab_Chart_Update_eqvol("E-mini SP 500", "E-mini SP 500 Chart", fx_pos, report_date)
fx_pos = Empty
' FX update section
' AUDJPY
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "Australian Dollar/Japanese Yen Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("AUDJPY", "AUDJPY Chart", fx_pos, report_date)
'fx_pos = Empty
'EURGBP
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "Euro/British Pound Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("EURGBP", "EURGBP Chart", fx_pos, report_date)
'fx_pos = Empty
'EURJPY
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "Euro/Japanese Yen Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("EURJPY", "EURJPY Chart", fx_pos, report_date)
'fx_pos = Empty
'EURCHF
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "Euro/Swiss Franc Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("EURCHF", "EURCHF Chart", fx_pos, report_date)
'fx_pos = Empty
'GBPJPY
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "British Pound/Japanese Yen Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("GBPJPY", "GBPJPY Chart", fx_pos, report_date)
'fx_pos = Empty
'AUDNZD
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "Australian Dollar/New Zealand Dollar Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("AUDNZD", "AUDNZD Chart", fx_pos, report_date)
'fx_pos = Empty
'EURAUD
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "Euro/Australian Dollar Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("EURAUD", "EURAUD Chart", fx_pos, report_date)
'fx_pos = Empty
'EURCAD
'For t = 7 To Sheets("FX").Cells(Rows.Count, 1).End(xlUp).Row
'If Sheets("FX").Cells(t, 1).Value Like "Euro/Canadian Dollar Future*" Then
'fx_pos = t
'Exit For
'End If
'Next t
'Call Tab_Chart_Update_fx("EURCAD", "EURCAD Chart", fx_pos, report_date)
'fx_pos = Empty
Application.ScreenUpdating = True
End Sub
Function Tab_Chart_Update_met(sh_name, ch_name, met_row, report_date)
If met_row = Empty Then Exit Function
lastdate = Sheets(sh_name).Cells(2, 1)
If lastdate = report_date Then
Sheets(sh_name).Cells(2, 4).Value = Sheets("Metals").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Metals").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Metals").Cells(met_row, 6).Value
End If
If lastdate < report_date Then
Sheets(sh_name).Cells(2, 4).EntireRow.Insert
Sheets(sh_name).Cells(2, 4).Value = Sheets("Metals").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Metals").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Metals").Cells(met_row, 6).Value
Sheets(sh_name).Cells(2, 1).Value = report_date
Sheets(sh_name).Cells(2, 1).NumberFormat = "dd/mm/yy;#"
End If
'Updating the OI charts
For i = 2 To 12
Sheets(ch_name).Cells(i, 1) = Sheets(sh_name).Cells(14 - i, 1)
Sheets(ch_name).Cells(i, 2) = Sheets(sh_name).Cells(14 - i, 3)
Next
End Function
Function Tab_Chart_Update_fx(sh_name, ch_name, fx_row, report_date)
If fx_row = Empty Then Exit Function
lastdate = Sheets(sh_name).Cells(2, 1).Value
If lastdate = report_date Then
Sheets(sh_name).Cells(2, 4).Value = Sheets("FX").Cells(fx_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("FX").Cells(fx_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("FX").Cells(fx_row, 6).Value
End If
If lastdate < report_date Then
Sheets(sh_name).Cells(2, 4).EntireRow.Insert
Sheets(sh_name).Cells(2, 4).Value = Sheets("FX").Cells(fx_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("FX").Cells(fx_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("FX").Cells(fx_row, 6).Value
Sheets(sh_name).Cells(2, 1).Value = report_date
Sheets(sh_name).Cells(2, 1).NumberFormat = "dd/mm/yy;#"
End If
'Updating the OI charts
For i = 2 To 12
Sheets(ch_name).Cells(i, 1) = Sheets(sh_name).Cells(14 - i, 1)
Sheets(ch_name).Cells(i, 2) = Sheets(sh_name).Cells(14 - i, 3)
Next
End Function
Function Tab_Chart_Update_energy(sh_name, ch_name, met_row, report_date)
If met_row = Empty Then Exit Function
lastdate = Sheets(sh_name).Cells(2, 1)
If lastdate = report_date Then
Sheets(sh_name).Cells(2, 4).Value = Sheets("Energy").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Energy").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Energy").Cells(met_row, 6).Value
End If
If lastdate < report_date Then
Sheets(sh_name).Cells(2, 4).EntireRow.Insert
Sheets(sh_name).Cells(2, 4).Value = Sheets("Energy").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Energy").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Energy").Cells(met_row, 6).Value
Sheets(sh_name).Cells(2, 1).Value = report_date
Sheets(sh_name).Cells(2, 1).NumberFormat = "dd/mm/yy;#"
End If
'Updating the OI charts
For i = 2 To 12
Sheets(ch_name).Cells(i, 1) = Sheets(sh_name).Cells(14 - i, 1)
Sheets(ch_name).Cells(i, 2) = Sheets(sh_name).Cells(14 - i, 3)
Next
End Function
Function Tab_Chart_Update_irv(sh_name, ch_name, met_row, report_date)
If met_row = Empty Then Exit Function
lastdate = Sheets(sh_name).Cells(2, 1)
If lastdate = report_date Then
Sheets(sh_name).Cells(2, 4).Value = Sheets("Interest Rate Volume").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Interest Rate Volume").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Interest Rate Volume").Cells(met_row, 6).Value
End If
If lastdate < report_date Then
Sheets(sh_name).Cells(2, 4).EntireRow.Insert
Sheets(sh_name).Cells(2, 4).Value = Sheets("Interest Rate Volume").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Interest Rate Volume").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Interest Rate Volume").Cells(met_row, 6).Value
Sheets(sh_name).Cells(2, 1).Value = report_date
Sheets(sh_name).Cells(2, 1).NumberFormat = "dd/mm/yy;#"
End If
'Updating the OI charts
For i = 2 To 12
Sheets(ch_name).Cells(i, 1) = Sheets(sh_name).Cells(14 - i, 1)
Sheets(ch_name).Cells(i, 2) = Sheets(sh_name).Cells(14 - i, 3)
Next
End Function
Function Tab_Chart_Update_eqvol(sh_name, ch_name, met_row, report_date)
If met_row = Empty Then Exit Function
lastdate = Sheets(sh_name).Cells(2, 1)
If lastdate = report_date Then
Sheets(sh_name).Cells(2, 4).Value = Sheets("Equity Volume").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Equity Volume").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Equity Volume").Cells(met_row, 6).Value
End If
If lastdate < report_date Then
Sheets(sh_name).Cells(2, 4).EntireRow.Insert
Sheets(sh_name).Cells(2, 4).Value = Sheets("Equity Volume").Cells(met_row, 8).Value
Sheets(sh_name).Cells(2, 3).Value = Sheets("Equity Volume").Cells(met_row, 7).Value
Sheets(sh_name).Cells(2, 2).Value = Sheets("Equity Volume").Cells(met_row, 6).Value
Sheets(sh_name).Cells(2, 1).Value = report_date
Sheets(sh_name).Cells(2, 1).NumberFormat = "dd/mm/yy;#"
End If
'Updating the OI charts
For i = 2 To 12
Sheets(ch_name).Cells(i, 1) = Sheets(sh_name).Cells(14 - i, 1)
Sheets(ch_name).Cells(i, 2) = Sheets(sh_name).Cells(14 - i, 3)
Next
End Function
Sub get_all_up_to_date()
Application.ScreenUpdating = False
Dim startdate, mem_date As Date
Dim day_back As Integer
day_back = Sheets("Links").Cells(15, 1).Value
startdate = Sheets("Gold").Cells(2, 1).Value
If startdate > Date Then
Exit Sub
End If
If Date - startdate > day_back Then startdate = Date - day_back
Do While startdate <= Date - 2
If Weekday(startdate) <> 7 And Weekday(startdate) <> 1 Then
Sheets("Main").Cells(1, 3).Value = startdate
Call download_data2
End If
'MsgBox ("")
startdate = startdate + 1
Loop
Application.ScreenUpdating = True
End Sub
I am not a developer but can understand the code 80% - 90% so I tried to run macro line by line using F8 key, it stucks on line (Workbooks.Open link_metal). I found some solutions of
Disabling the Automation security before Opening the workbook & then reseting it to orginal.
Adding Application.EnableEvents=False to code to stop firing the event handlers from other function of same workbook.
Copying Macro code in ThisWorkBook, instead of Module or file
BUT nothing seems to work. Advance thanks for help.

Try replacing the lines Workbooks.Open link_xxx with OpenWorkbookURL link_xxx and add this sub
Sub OpenWorkbookURL(url As String)
Dim oStream, oHTTP, xlsname As String
xlsname = "~download.xls"
Set oHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
With oHTTP
.Open "GET", url, False
.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64)"
.Send
If .Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
With oStream
.Open
.Type = 1
.Write oHTTP.ResponseBody
.SaveToFile xlsname, 2 ' 1 = no overwrite, 2 = overwrite
.Close
End With
Workbooks.Open xlsname, UpdateLinks:=False, ReadOnly:=True
End If
End With
End Sub

Related

Populating UserForm Data to an Excel Table

I have created a UserForm as shown by the image. The data from this has to be populated to an excel table named 'Database'. I have copied various VBA Codes from the internet to populate the table but all in vain. The code is as follows:
Sub ResetItem() ' The reset button coding
Sub Submit_Data()
Dim iRow As Long
If adminpanel.txtRowNumber.Value = "" Then
iRow = student.Range("A" & Rows.Count).End(xlUp).Row + 1
Else
iRow = adminpanel.txtRowNumber.Value
End If
With student.Range("A" & iRow)
.Offset(0, 0).Value = "=Row()-1"
.Offset(0, 1).Value = UserForm1.Doc_number.Value
.Offset(0, 2).Value = UserForm1.DocDate.Value
.Offset(0, 3).Value = UserForm1.Order_Number.Value
.Offset(0, 4).Value = UserForm1.Fleet_number.Value
.Offset(0, 5).Value = UserForm1.Maitenance_Type.Value
.Offset(0, 6).Value = UserForm1.ROF.Value
.Offset(0, 7).Value = UserForm1.System_Type.Value
.Offset(0, 8).Value = UserForm1.Asy_Type.Value
.Offset(0, 9).Value = UserForm1.Comments.Value
.Offset(0, 10).Value = UserForm1.OEM.Value
.Offset(0, 11).Value = UserForm1.Part_Number.Value
.Offset(0, 12).Value = UserForm1.SAP_Code.Value
.Offset(0, 13).Value = UserForm1.Unit.Value
.Offset(0, 14).Value = UserForm1.Start_Time.Value
.Offset(0, 15).Value = UserForm1.Finish_Time.Value
.Offset(0, 16).Value = UserForm1.Tech01.Value
.Offset(0, 17).Value = UserForm1.Tech02.Value
.Offset(0, 18).Value = UserForm1.Tech03.Value
.Offset(0, 19).Value = UserForm1.Distance.Value
End With
Call Reset_Form
Application.ScreenUpdating = True
MsgBox "Done"
End With
End Sub
Following code assumes that student is a name of a worksheet.
Sub Submit_Data()
Dim student As Worksheet
Dim iRow As Long
Set student = ThisWorkbook.Worksheets("student") 'assuming sheet name is student
If IsNumeric(adminpanel.txtRowNumber.Value) Then
iRow = CLng(adminpanel.txtRowNumber.Value)
Else
iRow = student.Cells(student.Rows.Count, "A").End(xlUp).Row + 1
End If
With UserForm1
student.Cells(iRow, 1).Formula = "=ROW() - 1"
student.Cells(iRow, 2).Resize(1, 19).Value2 = Array( _
.Doc_number.Value, _
.DocDate.Value, _
.Order_Number.Value, _
.Fleet_number.Value, _
.Maitenance_Type.Value, _
.ROF.Value, _
.System_Type.Value, _
.Asy_Type.Value, _
.Comments.Value, _
.OEM.Value, _
.Part_Number.Value, _
.SAP_Code.Value, _
.Unit.Value, _
.Start_Time.Value, _
.Finish_Time.Value, _
.Tech01.Value, _
.Tech02.Value, _
.Tech03.Value, _
.Distance.Value _
)
End With
Call Reset_Form
'Application.ScreenUpdating = True no need for it
MsgBox "Done"
Set student = Nothing
End Sub

how to loop through a wild card search with multiple matches. my code works but only finds 1st match from each sheet

Sub find_match_engine()
Dim mykeyword As String
Dim foundRange As Range
Dim LastRow As Long, ws As Worksheet
Dim Row As Variant
Dim Name As String
mykeyword = ThisWorkbook.Sheets("Search").Range("L2").Value
ThisWorkbook.Sheets("Search").Range("A3:K365").ClearContents
Application.ScreenUpdating = False
Set foundRange = ThisWorkbook.Sheets("Denyo").Range("A3:A60").Find(mykeyword & "*")
If foundRange Is Nothing Then
GoTo Line1
Exit Sub
Else
'While foundRange <> ""
Set ws = ThisWorkbook.Sheets("Search")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range("A" & LastRow).Value = "Denyo"
ws.Range("A" & LastRow).Offset(0, 1).Value = foundRange.Value
ws.Range("A" & LastRow).Offset(0, 2).Value = foundRange.Offset(0, 1).Value
ws.Range("A" & LastRow).Offset(0, 3).Value = foundRange.Offset(0, 2).Value
ws.Range("A" & LastRow).Offset(0, 4).Value = foundRange.Offset(0, 3).Value
ws.Range("A" & LastRow).Offset(0, 5).Value = foundRange.Offset(0, 4).Value
ws.Range("A" & LastRow).Offset(0, 6).Value = foundRange.Offset(0, 5).Value
ws.Range("A" & LastRow).Offset(0, 7).Value = foundRange.Offset(0, 6).Value
ws.Range("A" & LastRow).Offset(0, 8).Value = foundRange.Offset(0, 7).Value
ws.Range("A" & LastRow).Offset(0, 9).Value = foundRange.Offset(0, 8).Value
ws.Range("A" & LastRow).Offset(0, 10).Value = foundRange.Offset(0, 9).Value
'Wend
End If
Line1:
Set foundRange = ThisWorkbook.Sheets("Hitachi").Range("A3:A358").Find(mykeyword & "*")
If foundRange Is Nothing Then
GoTo Line2
'MsgBox "No Engine Model Files Found", vbInformation, "NO FILE HISTORY"
Exit Sub
Else
'While Name <> ""
Set ws = ThisWorkbook.Sheets("Search")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range("A" & LastRow).Value = "Hitachi"
ws.Range("A" & LastRow).Offset(0, 1).Value = foundRange.Value
ws.Range("A" & LastRow).Offset(0, 2).Value = foundRange.Offset(0, 1).Value
ws.Range("A" & LastRow).Offset(0, 3).Value = foundRange.Offset(0, 2).Value
ws.Range("A" & LastRow).Offset(0, 4).Value = foundRange.Offset(0, 3).Value
ws.Range("A" & LastRow).Offset(0, 5).Value = foundRange.Offset(0, 4).Value
ws.Range("A" & LastRow).Offset(0, 6).Value = foundRange.Offset(0, 5).Value
ws.Range("A" & LastRow).Offset(0, 7).Value = foundRange.Offset(0, 6).Value
ws.Range("A" & LastRow).Offset(0, 8).Value = foundRange.Offset(0, 7).Value
ws.Range("A" & LastRow).Offset(0, 9).Value = foundRange.Offset(0, 8).Value
ws.Range("A" & LastRow).Offset(0, 10).Value = foundRange.Offset(0, 9).Value
'Wend
End If
Line2:

Combobox not showing correct number of rows

I have an Excel (365) spreadsheet with two Comboboxes - Combobox1 and Combobox2 both are used to list the same data for different purposes on different tabs. My problem is that although I have changed listrows in both to the same number (20) only Combobox2 shows 20 rows. Combobox1 only shows the previous number of rows (15) although set to display 20. Anyone know how to get it to behave properly?
EDIT I have solved my origional problem but I would however be interested in using VBA to automatically update both listfillrange and listrows when a new row of data is added. I do have a macro that I use to add new data to my data table that could be adapted to also update listfillrange and listrows
Sub add_to_table_sa_3()
'Written by Keith Cooper 27/10/2021
Dim NewRow As Integer
NewRow = Worksheets("input").Range("E1").Value + 1
If Worksheets("input").Range("F1").Value <> 0 Then
MsgBox "There are errors. No data has been added!", vbOKOnly, "Warning!"
Exit Sub
End If
Worksheets("Data").Cells(NewRow, 1).Value = Worksheets("input").Range("B3").Value
Worksheets("Data").Cells(NewRow, 2).Value = Worksheets("input").Range("B4").Value
Worksheets("Data").Cells(NewRow, 3).Value = Worksheets("input").Range("B5").Value
Worksheets("Data").Cells(NewRow, 4).Value = Worksheets("input").Range("B6").Value
Worksheets("Data").Cells(NewRow, 5).Value = Worksheets("input").Range("B7").Value
Worksheets("Data").Cells(NewRow, 6).Value = Worksheets("input").Range("B8").Value
Worksheets("Data").Cells(NewRow, 7).Value = Worksheets("input").Range("B9").Value
Worksheets("Data").Cells(NewRow, 8).Value = Worksheets("input").Range("B10").Value
Worksheets("Data").Cells(NewRow, 9).Value = Worksheets("input").Range("B11").Value
Worksheets("Data").Cells(NewRow, 10).Value = Worksheets("input").Range("B12").Value
Worksheets("Data").Cells(NewRow, 11).Value = Worksheets("input").Range("B13").Value
Worksheets("Data").Cells(NewRow, 12).Value = Worksheets("input").Range("B14").Value
Worksheets("Data").Cells(NewRow, 13).Value = Worksheets("input").Range("B15").Value
Worksheets("Data").Cells(NewRow, 14).Value = Worksheets("input").Range("B16").Value
Worksheets("Data").Cells(NewRow, 15).Value = Worksheets("input").Range("B17").Value
Worksheets("Data").Cells(NewRow, 16).Value = Worksheets("input").Range("B18").Value
Worksheets("Data").Cells(NewRow, 17).Value = Worksheets("input").Range("B19").Value
Worksheets("Data").Cells(NewRow, 18).Value = Worksheets("input").Range("B20").Value
Worksheets("Data").Cells(NewRow, 19).Value = Worksheets("input").Range("B21").Value
Worksheets("Data").Cells(NewRow, 20).Value = Worksheets("input").Range("B22").Value
Worksheets("Data").Cells(NewRow, 21).Value = Worksheets("input").Range("B23").Value
Worksheets("Data").Cells(NewRow, 22).Value = Worksheets("input").Range("B24").Value
Worksheets("Data").Cells(NewRow, 23).Value = Worksheets("input").Range("B25").Value
Worksheets("Data").Cells(NewRow, 24).Value = Worksheets("input").Range("B26").Value
Worksheets("Data").Cells(NewRow, 25).Value = Worksheets("input").Range("B27").Value
Worksheets("Data").Cells(NewRow, 26).Value = Worksheets("input").Range("B28").Value
Worksheets("Data").Cells(NewRow, 27).Value = Worksheets("input").Range("B29").Value
Worksheets("Data").Cells(NewRow, 28).Value = Worksheets("input").Range("B30").Value
Worksheets("Data").Cells(NewRow, 29).Value = Worksheets("input").Range("B31").Value
Worksheets("Data").Cells(NewRow, 30).Value = Worksheets("input").Range("B32").Value
Worksheets("Data").Cells(NewRow, 31).Value = Worksheets("input").Range("B33").Value
Worksheets("Data").Cells(NewRow, 32).Value = Worksheets("input").Range("B34").Value
Worksheets("Data").Cells(NewRow, 33).Value = Worksheets("input").Range("B35").Value
Worksheets("Data").Cells(NewRow, 34).Value = Worksheets("input").Range("B36").Value
Worksheets("Data").Cells(NewRow, 35).Value = Worksheets("input").Range("B37").Value
'Range("B38") is a heading
Worksheets("Data").Cells(NewRow, 36).Value = Worksheets("input").Range("B39").Value
Worksheets("Data").Cells(NewRow, 37).Value = Worksheets("input").Range("B40").Value
Worksheets("Data").Cells(NewRow, 38).Value = Worksheets("input").Range("B41").Value
Worksheets("Data").Cells(NewRow, 39).Value = Worksheets("input").Range("B42").Value
Worksheets("Data").Cells(NewRow, 40).Value = Worksheets("input").Range("B43").Value
Worksheets("Data").Cells(NewRow, 41).Value = Worksheets("input").Range("B44").Value
Worksheets("Data").Cells(NewRow, 42).Value = Worksheets("input").Range("B45").Value
Worksheets("Data").Cells(NewRow, 43).Value = Worksheets("input").Range("B46").Value
Worksheets("Data").Cells(NewRow, 44).Value = Worksheets("input").Range("B47").Value
Worksheets("Data").Cells(NewRow, 45).Value = Worksheets("input").Range("B48").Value
Worksheets("Data").Cells(NewRow, 46).Value = Worksheets("input").Range("B49").Value
Worksheets("Data").Cells(NewRow, 47).Value = Worksheets("input").Range("B50").Value
Worksheets("Data").Cells(NewRow, 48).Value = Worksheets("input").Range("B51").Value
Worksheets("Data").Cells(NewRow, 49).Value = Worksheets("input").Range("B52").Value
Worksheets("Data").Cells(NewRow, 50).Value = Worksheets("input").Range("B53").Value
Worksheets("Data").Cells(NewRow, 51).Value = Worksheets("input").Range("B54").Value
Worksheets("Data").Cells(NewRow, 52).Value = Worksheets("input").Range("B55").Value
Sheets("Input").Select
Range("C2").Value = "Data added"
MsgBox "Data added", vbOKOnly, "Transfer Data"
Worksheets("input").Range("E1").Value = NewRow
Worksheets("input").Range("B3").Select
End Sub
Consider replacing the 52 lines transposing the data with one line inside a For/Next loop
Option Explicit
Sub add_to_table_sa_3()
Dim NewRow As Long, i as Long, arData
With Sheets("Input")
If .Range("F1").Value <> 0 Then
MsgBox "There are errors. No data has been added!", vbOKOnly, "Warning!"
Exit Sub
End If
arData = .Range("B3:B55").Value
NewRow = .Range("E1").Value + 1
End With
With Sheets("Data")
For i = 1 To 35
.Cells(NewRow, i) = arData(i, 1)
Next
'Range("B38") is a heading
For i = 37 To 65
.Cells(NewRow, i - 1) = arData(i, 1)
Next
'Range("B68") is a heading
For i = 67 To UBound(arData)
.Cells(NewRow, i - 2) = arData(i, 1)
Next
Sheet1.ComboBox1.ListFillRange = "'" & .Name & "'!A2:A" & NewRow
Sheet6.ComboBox2.ListFillRange = "'" & .Name & "'!A2:A" & NewRow
End With
With Sheets("Input")
.Range("C2").Value = "Data added"
.Range("E1").Value = NewRow
.Activate
.Range("B3").Select
End With
MsgBox "Data added row " & NewRow, vbOKOnly, "Transfer Data"
End Sub

macros can't see a worksheet - 'runtime error 9'

I have 2 sheets and 1 macros that pastes values from one to another. The macros is working. I copied it and changed it a bit. But it can't run -
'run time error 9'
which is visibility issue.
All sheets are in same excel file.
original macros code, it works:
Sub original()
For j = 18 To 28
Worksheets("Express_vnzp").Select
srok = Cells(26, j).Value
stav = Cells(31, j).Value
komis = Cells(28, j).Value
stavka_privlech = Cells(29, j).Value
For i = 10 To 12
PD = Cells(i, 17).Value
Worksheets("Ðàñ÷åòû").Select
Cells(3, 2).Value = stav
Cells(4, 2).Value = srok
Cells(5, 2).Value = komis
Cells(7, 2).Value = stavka_privlech
Cells(15, 2).Value = PD
marzha2 = Cells(23, 2).Value
Worksheets("Express_vnzp").Select
Cells(i, j).Value = marzha2
Next
Next
End Sub
I copied and changed i,j - not working.
Sub erj()
For j = 3 To 4
Worksheets("creditcard").Select
srok = Cells(26, j).Value
stav = Cells(31, j).Value
komis = Cells(28, j).Value
stavka_privlech = Cells(29, j).Value
For i = 5 To 6
PD = Cells(i, 17).Value
Worksheets("ras").Select
Cells(3, 2).Value = stav
Cells(4, 2).Value = srok
Cells(5, 2).Value = komis
Cells(7, 2).Value = stavka_privlech
Cells(15, 2).Value = PD
marzha2 = Cells(23, 2).Value
Worksheets("creditcard").Select
Cells(i, j).Value = marzha2
Next
Next
End Sub
gives 'runtime error', its visibility issue.

Trying to delete empty rows in VBA with command button

i'm trying to solve a problem of mine and i'm pretty much a newbie in VBA.
I'm trying to make a quotation out of excel utilizing user form.
Transferring data is doable from the user form, but am having some difficulty to complete the quotation:
1. Creating new empty row base on input in user form
2. assign input to different rows and deleting any empty rows if there are no input.
This is my userform:
Private Sub okaybutton_Click()
'Make quotation activate
Sheet11.Activate
'Trasnfer Information sheet
Cells(2, 6).Value = DateBox.Value
Cells(6, 2).Value = "Company: " + CompanyBox.Value
Cells(8, 2).Value = "State: " + StateBox.Value
Cells(9, 2).Value = "Name: " + PICBox.Value
Cells(10, 2).Value = "Contact Number: " + ContactCustomer.Value
Cells(7, 2).Value = "Address: " + AddressBox.Value
Cells(7, 6).Value = SEBox.Value
Cells(8, 6).Value = CNBox.Value
Cells(11, 2).Value = CusEmail.Value
Cells(9, 6).Value = ACemail.Value
If PTWrequire.Value = True Then
Cells(13, 2).Value = "PTW application or safety induction required at site"
End If
If ESDrequire.Value = True Then
Cells(13, 2).Value = Cells(13, 2).Value & " " & " & ESD Attire required."
End If
'SupplySide information sheet
'Determine emptyRow
nextrow = WorksheetFunction.CountA(Range("B:B"))
nextrow1 = WorksheetFunction.CountA(Range("B:B")) + 1
nextrow2 = WorksheetFunction.CountA(Range("B:B")) + 2
'Dim nextrow As Long
'nextrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
'flow measurement point 1
If FlowMeasure1.Value = True Then
Cells(nextrow, 3).Value = "Flow measurement, Measures dry air flow capacity."
If Hottap1.Value = "Yes" Then
Cells(nextrow, 3).Value = Cells(nextrow, 3).Value & "- perform hot tapping on " & "Main header size: " & Pipesize1.Value & """."
Else
Cells(nextrow, 3).Value = Cells(nextrow, 3).Value & " Main header size: " & Pipesize1.Value & """."
End If
If Pipesize1.Value = 2 Then
Cells(nextrow, 4).Value = "3700"
ElseIf Pipesize1.Value = 2.5 Then
Cells(nextrow, 4).Value = "3706"
ElseIf Pipesize1.Value = 3 Then
Cells(nextrow, 4).Value = "3945"
ElseIf Pipesize1.Value = 4 Then
Cells(nextrow, 4).Value = "3971"
ElseIf Pipesize1.Value = 5 Then
Cells(nextrow, 4).Value = "3971"
ElseIf Pipesize1.Value = 6 Then
Cells(nextrow, 4).Value = "4080"
End If
If SSquantity1.Value > 0 Then
Cells(nextrow, 2).Value = SSquantity1.Value
End If
'flow measurement point 2
If Hottap2.Value = "Yes" Then
Cells(nextrow1, 3).Value = "Flow measurement, Measures dry air flow capacity." & "- perform hot tapping on " & "Main header size: " & Pipesize2.Value & """."
ElseIf Hottap2.Value = "No" Then
Cells(nextrow1, 3).Value = Cells(nextrow1, 3).Value & " Main header size: " & Pipesize2.Value & """."
End If
If Pipesize2.Value = 2 Then
Cells(nextrow1, 4).Value = "3700"
ElseIf Pipesize2.Value = 2.5 Then
Cells(nextrow1, 4).Value = "3706"
ElseIf Pipesize2.Value = 3 Then
Cells(nextrow1, 4).Value = "3945"
ElseIf Pipesize2.Value = 4 Then
Cells(nextrow1, 4).Value = "3971"
ElseIf Pipesize2.Value = 5 Then
Cells(nextrow1, 4).Value = "3971"
ElseIf Pipesize2.Value = 6 Then
Cells(nextrow1, 4).Value = "4080"
End If
If SSquantity2.Value > 0 Then
Cells(nextrow1, 2).Value = SSquantity2.Value
End If
'flow measurement point 3
If Hottap3.Value = "Yes" Then
Cells(nextrow2, 3).Value = "Flow measurement, Measures dry air flow capacity." & "- perform hot tapping on " & "Main header size: " & Pipesize3.Value & """."
ElseIf Hottap3.Value = "No" Then
Cells(nextrow2, 3).Value = Cells(nextrow2, 3).Value & " Main header size: " & Pipesize3.Value & """."
End If
If Pipesize3.Value = 2 Then
Cells(nextrow2, 4).Value = "3700"
ElseIf Pipesize3.Value = 2.5 Then
Cells(nextrow2, 4).Value = "3706"
ElseIf Pipesize3.Value = 3 Then
Cells(nextrow2, 4).Value = "3945"
ElseIf Pipesize3.Value = 4 Then
Cells(nextrow2, 4).Value = "3971"
ElseIf Pipesize3.Value = 5 Then
Cells(nextrow2, 4).Value = "3971"
ElseIf Pipesize3.Value = 6 Then
Cells(nextrow2, 4).Value = "4080"
End If
If SSquantity3.Value > 0 Then
Cells(nextrow2, 2).Value = SSquantity3.Value
End If
End If
On Error Resume Next
Worksheet.Columns("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End Sub

Resources