tr1face
New Member
- Joined
- Jan 7, 2021
- Messages
- 18
- Office Version
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Hi Guys,
I have the following Vba code which doesn't seem to work in Excel 2016, while I didn't encountered any errors in Excel 2010 environment. I am suspecting Microsoft Office 14 library vs 16 library, and I am thinking if someone can re-write this so I can run it.
Error received is that Sub or function is not defined.
Vba code:
Thank you in advance!!
I have the following Vba code which doesn't seem to work in Excel 2016, while I didn't encountered any errors in Excel 2010 environment. I am suspecting Microsoft Office 14 library vs 16 library, and I am thinking if someone can re-write this so I can run it.
Error received is that Sub or function is not defined.
Vba code:
VBA Code:
Sub Creator()
Application.ScreenUpdating = False
Dim i As Long, v As Variant, srcWS As Worksheet, fVisRow As Long, lVisRow As Long, x As Long, lrow As Long, y As Long
Set srcWS = Sheets("Data")
v = srcWS.Range("A6", srcWS.Range("A" & srcWS.Rows.Count).End(xlUp)).Value
With CreateObject("scripting.dictionary")
For i = 1 To UBound(v)
If Not .Exists(v(i, 1)) Then
.Add v(i, 1), Nothing
With srcWS.Range("A5")
.CurrentRegion.AutoFilter 1, v(i, 1)
fVisRow = srcWS.AutoFilter.Range.Offset(1, 0).SpecialCells(xlCellTypeVisible).Cells(1, 1).Row
lVisRow = srcWS.Cells(srcWS.Rows.Count, "A").End(xlUp).Row
Sheets("Invoice_Template").Copy after:=Sheets(Sheets.Count)
With ActiveSheet
.Name = v(i, 1)
.Range("G3") = srcWS.Range("B" & fVisRow)
.Range("G4") = srcWS.Range("A" & fVisRow)
.Range("G5") = Split(srcWS.Range("F" & fVisRow), "-")(0) & "-" & Split(srcWS.Range("F" & lVisRow), "-")(1)
.Range("G6") = srcWS.Range("E" & fVisRow)
.Range("G7") = srcWS.Range("Q" & fVisRow)
.Range("B10:B13") = WorksheetFunction.Transpose(srcWS.Range("M" & fVisRow).Resize(, 4))
For x = fVisRow To lVisRow
lrow = .Range("C:C").Find("Total:", LookIn:=xlValues, lookat:=xlWhole).Row
.Cells(lrow - 1, 1).EntireRow.Insert
Intersect(srcWS.Rows(x), srcWS.Range("C:C,G:G,H:L")).Copy .Range("A" & lrow - 1)
lrow = .Range("C:C").Find("Total:", LookIn:=xlValues, lookat:=xlWhole).Row
.Cells(lrow - 1, 1).Resize(2).EntireRow.Insert
.Range("A" & lrow - 1).Resize(2) = WorksheetFunction.Transpose(Array("Legacy Contract No.:", srcWS.Range("D" & x)))
lrow = .Range("C:C").Find("Total:", LookIn:=xlValues, lookat:=xlWhole).Row
.Range("B" & lrow - 3).Resize(2) = WorksheetFunction.Transpose(Array(srcWS.Range("F" & x), srcWS.Range("H" & x)))
Next x
.Range("D" & lrow & ":G" & lrow).Formula = "=sum(D19:D" & lrow - 1 & ")"
End With
End With
End If
Next i
srcWS.Range("A5").AutoFilter
End With
Application.ScreenUpdating = True
End Sub
Thank you in advance!!