"unknown error" on vba script

"unknown error" on vba script

Any idea why I get "unknown error" on line 32?

  1. Option Explicit
  2. Sub updateCSV()

  3. Dim wb As Workbook
  4. Dim ws As Worksheet
  5. Dim newWS As Worksheet
  6. Dim i As Long
  7. Dim z As Long
  8. Dim lr As Long
  9. Dim desc As Variant, created As Variant, amt As Variant, fee As Variant

  10. 'Set Objects
  11. Set wb = ActiveWorkbook
  12. Set ws = wb.ActiveSheet
  13. Set newWS = Sheets.Add

  14. 'Vars -> Assumes headers are in row 1
  15. desc = Application.Match("Customer Description", ws.Rows(1), 0)
  16. created = Application.Match("Created (UTC)", ws.Rows(1), 0)
  17. amt = Application.Match("Amount", ws.Rows(1), 0)
  18. fee = Application.Match("Fee", ws.Rows(1), 0)
  19. z = 1

  20. 'Format newWS
  21. With newWS
  22.     .Cells(1, 1).Value = "description"
  23.     .Cells(1, 2).Value = "date"
  24.     .Cells(1, 3).Value = "Amount"
  25. End With

  26. 'Get data from ws
  27. With ws
  28.     lr = .Cells(.Rows.Count, 1).End(xlUp).Row
  29.     'Assumes data starts at row 2 and headers are on row 1
  30.     For i = 2 To lr
  31.         z = z + 1
  32.         newWS.Cells(z, 1).Value = ws.Cells(i, desc).Value
  33.         newWS.Cells(z, 2).Value = Format(ws.Cells(i, created).Value, "mm/dd/yyyy")
  34.         newWS.Cells(z, 3).Value = ws.Cells(i, amt).Value
  35.     Next i
  36.     'Add values back
  37.     For i = 2 To lr
  38.         z = z + 1
  39.         newWS.Cells(z, 1).Value = "stripe fee: " & ws.Cells(i, desc).Value
  40.         newWS.Cells(z, 2).Value = Format(ws.Cells(i, created).Value, "mm/dd/yyyy")
  41.         newWS.Cells(z, 3).Value = ws.Cells(i, fee).Value * -1
  42.     Next i
  43. End With

  44. 'Fit
  45. newWS.Columns.AutoFit

  46. End Sub
    • Sticky Posts

    • Introducing Forms in Zoho Sheet

      We hereby bring you the power of ​forms in Zoho Sheet. ​Now, build and create your own customized forms using Zoho Sheet. Be it compiling a questionnaire or rolling out a survey, Zoho Sheet can do it all for you. Forms is an excellent feature that helps you collect information in the simplest of ways and having it in Zoho Sheet takes it a notch higher. Build Simple yet Powerful forms Building forms using Zoho Sheet is fairly simple. The exclusive 'Form' tab lets you create one quickly. Whether you
    • What's new in Zoho Sheet: Simplify data entry and collaboration

      Hello, Zoho Sheet community! Last year, our team was focused on research and development so we could deliver updates that enhance your spreadsheet experience. This year, we’re excited to deliver those enhancements—but we'll be rolling them out incrementally
    • Slicers are now available in Zoho Sheet—filter your data interactively

      At Zoho Sheet, we diligently track user requests and feedback. In line with this, based on extensive user requests, we've integrated Slicers to pivot tables and are delighted to announce its release. Slicers are interactive visual filters that have add,
    • Introducing Data Bars: Graphically represent changes in data within the cells

      Conditional formatting has helped millions of spreadsheet users analyze and highlight their data more efficiently. In addition to the classic rules, color scales, and icon sets available in Zoho Sheet, you can now apply Data Bars, a convenient method
    • Feature enhancement: Highlight rows based on a cell value

      Hello Sheet users, We're excited to announce a new feature enhacement, shaped directly by your valuable feedback! As you might know, conditional formatting is a great tool for anyone dealing with large data sets. Previously, if you’ve ever wanted to draw