Skip to content

Instantly share code, notes, and snippets.

@t81lal
Created January 2, 2019 18:13
Show Gist options
  • Save t81lal/13598f3a2871e5e29b268b4fa95f8f42 to your computer and use it in GitHub Desktop.
Save t81lal/13598f3a2871e5e29b268b4fa95f8f42 to your computer and use it in GitHub Desktop.
Option Explicit
Public Const BankDateCol = "A"
Public Const BankNameCol = "C"
Public Const BankAmountCol = "D"
Public Const BankPropertyCol = "F"
Sub CopyValue(BankRow As Long, PropRow As Long, BankCol As String, PropertyCol As Long, PropertySheet As Worksheet)
PropertySheet.Cells(PropRow, PropertyCol).Value = Sheet1.Range(BankCol & BankRow).Value
End Sub
Sub CopyPropertyData()
Dim RowOffset As Long
Dim ColOffset As Long
RowOffset = ActiveCell.Row
ColOffset = ActiveCell.Column
Dim PropertyName As String
PropertyName = ActiveSheet.Cells(RowOffset, ColOffset).Value
RowOffset = RowOffset + 1
Dim RowIndex As Long
RowIndex = 0
Dim Row As Long
For Row = 1 To Sheet1.UsedRange.Rows.Count
If Trim(Sheet1.Range(BankPropertyCol & Row).Value) = PropertyName Then
ActiveSheet.Cells(RowIndex + RowOffset, ColOffset) = ((RowIndex + 1) & ".")
Call CopyValue(Row, RowIndex + RowOffset, BankDateCol, ColOffset + 1, ActiveSheet)
Call CopyValue(Row, RowIndex + RowOffset, BankNameCol, ColOffset + 2, ActiveSheet)
Call CopyValue(Row, RowIndex + RowOffset, BankAmountCol, ColOffset + 3, ActiveSheet)
RowIndex = RowIndex + 1
End If
Next Row
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment