I'm trying to write a code to Insert Project Costs on a Worksheet. I am not an Excel Expert so I am using this tutorial to guide me: https://www.youtube.com/watch?v=NO10WZ2prDQ (it's in Portuguese, but you can see what the UserForm does within the first minute of the video)
What I want to do is insert costs in a worksheet and then filter them to generate a report of all project costs and their categories.
Here's my UserForm: https://i.sstatic.net/pIzwT.png
When coding for the Insert Button ('Inserir Custo'), here's what I typed:
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Plan4")
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
ws.Cells(iRow, 1).Value = Me.ListBox1.Value
ws.Cells(iRow, 2).Value = Me.TextBox1.Value
Me.ListBox1.Value = ""
Me.TextBox1.Value = ""
Me.TextBox1.SetFocus
Excel shows an error on the iRow line of the code, but I dont know whats wrong. When clicking that button, I want the code to insert the results of the ListBox1 in a cell, and the TextBox1 in another cell, next to it.
Can someone help me? What did I write wrong?
Thanks!
iRowinstead:iRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row + 1