Vindaloo
New Member
- Joined
- Jul 15, 2014
- Messages
- 29
I am new to the forums and am teaching myself VBA. I am trying to paste cells from an input tab, send them to the appropriate tab which is the variable, Tabref. When the macro finds the correct tab, it will then match criteria in 3 separate columns, which are Abbrev, Merchant ID, and Amount. If the row in the columns matches all 3, it should paste the variables Deposit_Date and Deposit_Number into their appropriate columns. I am not able to make reference formulas to concatenate on the other tabs because there are over 100 tabs and they would slow down the workbook. Also, this would interfere with existing scripts. I am getting compiling errors such as not having a Do with a Loop.
Thank you for any help you can provide,
Oren
Sub Populate_CC_Activity()
'
' Populate_CC_Activity Macro
' Pull Bank Deposit Dates and Deposit numbers from the Activity Reports Tab and paste them into the appropriate Tab
'
Dim Tabref As String
Dim Abbrev As String
Dim Merchant_ID As String
Dim Amount As String
Dim Deposit_Date As String
Dim Deposit_Number As String
Dim i As Integer
i = 3
With Worksheets("Activity Reports")
Do Until .Cells(i, 1).Value = ""
Tabref = .Cells(i, 13).Value
Abbrev = .Cells(i, 10).Value
Merchant_ID = .Cells(i, 9).Value
Amount = .Cells(i, 5).Value
Deposit_Date = .Cells(i, 11).Value
Deposit_Number = .Cells(i, 12).Value
Dim j As Integer
Cells(i, 11).Select
Selection.Copy
Sheets(Tabref).Select
j = 5
If ActiveSheet.Cells(j, 2) = Abbrev And ActiveSheet.Cells(j, 4) = Amount And ActiveSheet.Cells(j, 5) = Merchant_ID Then
Cells(j, 6).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Activity Reports").Select
i = i + 1
Loop
End With
End Sub
End Sub
Thank you for any help you can provide,
Oren
Sub Populate_CC_Activity()
'
' Populate_CC_Activity Macro
' Pull Bank Deposit Dates and Deposit numbers from the Activity Reports Tab and paste them into the appropriate Tab
'
Dim Tabref As String
Dim Abbrev As String
Dim Merchant_ID As String
Dim Amount As String
Dim Deposit_Date As String
Dim Deposit_Number As String
Dim i As Integer
i = 3
With Worksheets("Activity Reports")
Do Until .Cells(i, 1).Value = ""
Tabref = .Cells(i, 13).Value
Abbrev = .Cells(i, 10).Value
Merchant_ID = .Cells(i, 9).Value
Amount = .Cells(i, 5).Value
Deposit_Date = .Cells(i, 11).Value
Deposit_Number = .Cells(i, 12).Value
Dim j As Integer
Cells(i, 11).Select
Selection.Copy
Sheets(Tabref).Select
j = 5
If ActiveSheet.Cells(j, 2) = Abbrev And ActiveSheet.Cells(j, 4) = Amount And ActiveSheet.Cells(j, 5) = Merchant_ID Then
Cells(j, 6).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Activity Reports").Select
i = i + 1
Loop
End With
End Sub
End Sub