tmteast
New Member
- Joined
- Apr 12, 2021
- Messages
- 7
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
- MacOS
- Web
Hello, I am an IT Tech for a small business and rarely have to work with VBA. In this case I have spent about an hour reading and trying things and I am not getting the desired result. I am hoping this is a pretty basic request and am very thankful for the help.
I have a data set (Expenses) from our cloud accounting software (ParkStreet) that we are migrating to our on premise db (QB). I have a Macro that is reading a Table on another sheet. It Finds and Replaces things like Vendor Names, Accounts, Classes, etc. Making sure they are a perfect match before going into the On-Premise system.
I have a couple of queries I want to run after that initial operation is complete.
If
"Chargebacks" = found
Then
Prompt MsgMox "Chargebacks were found in this dataset. Review Data BEFORE importing."
If
"Other Distributor Charges" = found
Then
Prompt MsgMox "Other Dist Charges were found in this dataset. Review Data BEFORE importing."
Here is the code as it sits now:
I have a data set (Expenses) from our cloud accounting software (ParkStreet) that we are migrating to our on premise db (QB). I have a Macro that is reading a Table on another sheet. It Finds and Replaces things like Vendor Names, Accounts, Classes, etc. Making sure they are a perfect match before going into the On-Premise system.
I have a couple of queries I want to run after that initial operation is complete.
If
"Chargebacks" = found
Then
Prompt MsgMox "Chargebacks were found in this dataset. Review Data BEFORE importing."
If
"Other Distributor Charges" = found
Then
Prompt MsgMox "Other Dist Charges were found in this dataset. Review Data BEFORE importing."
Here is the code as it sits now:
VBA Code:
Sub AccountsPStoQB()
'
' AccountsPStoQB Macro
'
'
'PURPOSE: Find & Replace a list of text/values throughout entire workbook from a table
'SOURCE: [URL='http://www.TheSpreadsheetGuru.com/the-code-vault']www.TheSpreadsheetGuru.com/the-code-vault[/URL]
Dim sht As Worksheet
Dim fndList As Integer
Dim rplcList As Integer
Dim tbl As ListObject
Dim myArray As Variant
'Create variable to point to your table
Set tbl = Worksheets("InventoryItems").ListObjects("Table2")
'Create an Array out of the Table's Data
Set TempArray = tbl.DataBodyRange
myArray = Application.Transpose(TempArray)
'Designate Columns for Find/Replace data
fndList = 1
rplcList = 2
'Loop through each item in Array lists
For x = LBound(myArray, 1) To UBound(myArray, 2)
'Loop through each worksheet in ActiveWorkbook (skip sheet with table in it)
For Each sht In ActiveWorkbook.Worksheets
If sht.Name <> tbl.Parent.Name Then
sht.Cells.Replace What:=myArray(fndList, x), Replacement:=myArray(rplcList, x), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
End If
Next sht
Next x
If Sheets
End Sub
Last edited by a moderator: