Your attachment works in this file but when I apply the macro to the actual file I get a Run-Time error '13' Type Mismatch
result(j, 6) = data(i, n) * (-1)
I am going to apply it to the template I attached above and see if it works on the template.
EDIT:
Do I only copy this code
Option Explicit
Option Compare Text
Sub test()
Dim iheaderarr, sh, data, result, fundrng As Range, lrow As Long, i As Long, n As Long, j As Long, colcount As Long, _
isum As Double, fundname As String
iheaderarr = Array("Date", "GL#", "FUND#", "Department#", "Project#", "$amount")
Application.ScreenUpdating = 0
For Each sh In ThisWorkbook.Sheets
With sh
Set fundrng = .UsedRange.Find("fund", , xlValues, xlWhole)
If Not fundrng Is Nothing Then
lrow = .Cells(Rows.Count, "c").End(xlUp).Row
If lrow > 7 Then
fundname = fundrng.Offset(, 1).Value
data = .Range("c1:n" & lrow)
colcount = UBound(data, 2)
ReDim result(1 To (lrow - 7) * 12, 1 To 6)
For i = fundrng.Row + 4 To lrow - 1
If data(i, 1) <> "" Then
For n = 2 To colcount
If data(i, n) <> "" Then
j = j + 1
result(j, 1) = data(i, 1)
If data(i, n) <> Abs(isum) Then
result(j, 6) = data(i, n) * (-1)
isum = isum + result(j, 6)
Else
result(j, 6) = data(i, n)
result(j, 2) = "OFFSETT"
End If
result(j, 3) = fundname
End If
Next
isum = 0
End If
Next
End If
Set fundrng = Nothing
End If
If j > 0 Then
.Range("b" & lrow + 7).Resize(, 6) = iheaderarr
.Range("b" & lrow + 8).Resize(j, 6) = result
j = 0
End If
End With
Next
Application.ScreenUpdating = 1
End Sub
EDIT 2: When I run the code on the template file nothing happens. I believe it executes but no results come back or any messages.
Bookmarks