Cityroller
New Member
- Joined
- Oct 17, 2017
- Messages
- 6
I'm very new to VBA. Coming here is the next step, as I've been working on this problem for a few days. Agonizingly, I had something very similar working before, it works on the other worksheet(sort of) and I don't know how to get back to where it was working.
I've looked around the web at different code examples. I need a macro to get to the next empty row, and have found many.
The first problem began last week when it started adding spaces between the rows, from double-spaced to quadruple, all with the same macro.
The most recent problem seems to be that any formula I use in the macro returns the row where the active cell is located, seeming to ignore the formula at all.
The spreadsheet is divided into two sheets: "Balance" and "Debits." The macro that posts the transactions to the debits sheet works. Almost flawlessly. I have to subtract 2 at the end because it wants to add extra spaces. Other than that, it does what I want.
The macro to post transactions to the "Balance" sheet doesn't work at all.
Thanks in advance!
Shane
I've looked around the web at different code examples. I need a macro to get to the next empty row, and have found many.
The first problem began last week when it started adding spaces between the rows, from double-spaced to quadruple, all with the same macro.
Code:
Public Sub rowFinder(txt1 As Integer, txt2 As Double, txt3 As String, oB1 As String, oB2 As String)
Dim ws As Worksheet, col As Integer, lastRow As Integer
Dim cOver As Integer, tbl As String, rng As String, rng2 As String, AC As String
Dim ACI As Integer
Set ws = Sheets("Balance")
AC = Application.Caller
ACI = CInt(Right(AC, 2))
If ACI = 36 Then
rng = "b31"
rng2 = "f31"
tbl = "Table2"
If oB1 = True Then
cOver = 2
Else: cOver = 3
End If
End If
lastRow = Sheets("Balance").ListObjects(tbl).Range.Columns(1).Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row + 1
Sheets("Balance").ListObjects(tbl).Range(lastRow, 1) = txt1
Sheets("Balance").ListObjects(tbl).Range(lastRow, cOver) = txt2
Sheets("Balance").ListObjects(tbl).Range(lastRow, 5) = txt3
Debug.Print lastRow, cOver, tbl
End Sub
The most recent problem seems to be that any formula I use in the macro returns the row where the active cell is located, seeming to ignore the formula at all.
The spreadsheet is divided into two sheets: "Balance" and "Debits." The macro that posts the transactions to the debits sheet works. Almost flawlessly. I have to subtract 2 at the end because it wants to add extra spaces. Other than that, it does what I want.
Code:
lastRow = Sheets("Debits").ListObjects(tbl).Range.Columns(bCol).Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row - 2
The macro to post transactions to the "Balance" sheet doesn't work at all.
Thanks in advance!
Shane