Update Vba Code

tr1face

New Member
Joined
Jan 7, 2021
Messages
18
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. 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:
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!!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
That does not answer my question.
 
Upvote 0
I am sorry, but there's nothing highlighted. It's just not working at all, with the Compile error message saying is incompatible with the version,platform, etc. All the above enumerated rows are red while nothing happens :(
 
Upvote 0
The Sub Creator() is yellow if that's what you're asking
 
Upvote 0
There is absolutely nothing wrong with the code you have posted. If you are getting a "Sub or Function is not defined" error then the offending part of the code should get highlighted in blue.
What is highlighted.
 
Upvote 0
Solution
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Macro Help Needed - OzGrid Free Excel/VBA Help Forum
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
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