VBA: Loop to map figures from 2 different workbooks - excel

I have 2 different excel workbooks, one is called DATA and one is called ReportTemplate. So now i need to insert data from DATA to corresponding row/column in ReportTemplate.
How I am doing now is, for example:
'Others ( this is for other currencies)
DATA_FILE.activate
Sheets("SA_FX_2").select
SRC_SA_FX_2_D25 = Range("D25").Value
SRC_SA_FX_2_E25 = Range("E25").Value
SRC_SA_FX_2_F25 = Range("F25").Value
SRC_SA_FX_2_G25 = Range("G25").Value
SRC_SA_FX_2_H25 = Range("H25").Value
REPORTTEMPLATE_FILE.activate
Sheets("SA_FX_2").select
Range("D36").Value = SRC_SA_FX_2_D25
Range("E36").Value = SRC_SA_FX_2_E25
Range("F36").Value = SRC_SA_FX_2_F25
Range("G36").Value = SRC_SA_FX_2_G25
Range("H36").Value = SRC_SA_FX_2_H25
The SRC_SA_FX_2_X25 is to store the values for that particular cells in DATA, then insert it into Range("X36").Value in REPORTTEMPLATE. So currently I am doing the "mapping" in a hard-coded way.
This is how my DATA looks like:
DATA TEMPLATE
And this is how my REPORTTEMPLATE looks like:REPORTTEMPLATE
For the "Others" and above currencies, they are all fixed, so I can just hard code the cells.
However, if there is any new currency, my macro should detect that, then choose the currency in the drop down list, and do the mapping.
How can I actually parameterize my codes above in order to the mapping for the rest of the currencies?
Thank you for your advice.

A simple way would be to MATCH them like:
'we look for rows 3 to 5 of DATA_FILE in REPORTTEMPLATE_FILE
Dim i As Long, OutRow As Variant, wsIn As Worksheet, wsOut As Worksheet
Set wsIn = DATA_FILE.Sheets("SA_FX_2")
Set wsOut = REPORTTEMPLATE_FILE.Sheets("SA_FX_2")
For i = 3 To 5
'get the row of the active item in REPORTTEMPLATE_FILE
OutRow = Application.Match(wsIn.Cells(i, 3).Value2, wsOut.Columns(3), 0)
If Not IsNumeric(OutRow) Then OutRow = Application.Match("-- Please Select Currency --", wsOut.Columns(3), 0) 'not there -> new line
wsOut.Range("C" & OutRow & ":H" & OutRow).Value2 = wsIn.Range("C" & i & ":H" & i).Value2
Next
Just change the For i = 3 To 5 to fit your needs and check, if the "-- Please Select Currency --" does match.
If you have any questions or problems, just ask ;)

Related

Various Troubles with VBA (Excel Maros)

I would briefly like to start off with I have never touched VBA let alone excel macros until a couple days ago.
I need to transfer and convert data of 1000 rows (4 columns) from one sheet (Sheet 1) to another (Sheet 2).
A quick description of what I'm given, each row is an object, I have 4 columns.
The first one (column) is the Object ID, the second one is the Object name, the third one explain the what of the object and the final column explains the how. This is a very simplified version as explaining the entire project would be complicated.
On the second sheet, I have 6000 rows all with the object's IDs and Names however the What and How are missing.
My goal is to take the what and how of an object from this sheet, convert the wording to a form in which the second sheet accepts and make sure it gets added to the proper ID.
I have tried multiple code samples I have found online to try and select and organize into tables (arrays) the information from the first sheet, I failed miserably.
Converting the What and How
The second sheet has a very strict format in which everything can be written. In my mind (Lua is my main language), I would have a dictionary or table with all possible ways of the How/What could be written on the first sheet and checking each one to see if they match then change it to the corresponding sheet 2 format. Let me show you. (This is the what. There'd be another table for the how which I'll show below)
local MType = {
["Industrial"] = {"MILPRO : Industrial","Industrial"};
["Public Saftey"] = {"MILPRO : Public Saftey", "Public Saftey"};
["Military"] = {"MILPRO : Military","Military"};
["Paddling"] = {"Recreation : Paddling","Paddling"};
["Sporting Goods"] = {"Recreation : Sporting Goods","Sporting Goods"};
["Outdoor"] = {"Recreation : Outdoor", "Outdoor"};
["Hook & Bullet"] = {"Recreation : Hook & Bullet", "Hook & Bullet"};
["Marine"] = {"Recreation : Marine","Marine","Marina / Lodge"};
["Sailing"] = {"Recreation : Sailing","Sailing"};
["Unknown"] = {"UNKNOWN"}
}
local CType = {
["Multi-Door"] = {"Multi-Door","Multi-door"};
["Dealer & Distributor"] = {"Distributor","Dealer & Distributor"};
["Independant Specialty"] = {"Independant Specialty","Specialty"};
["OEM"] = {"OEM","OEM - VAR"};
["Internal"] = {"Internal","Sales Agency","Repairs Facility"};
["Rental"] = {"Rental / Outfitter", "Rental"};
["End User"] = {"End User"};
["Institution"] = {"Institution","Government Direct"};
["Unknown"] = {"UNKNOWN"}
}
The first position in each table (table = the curly brackets) is the format in which the second sheet accepts. The rest in the tables is how they might be written in the first sheet. (This is how I imagine this would go down. Idk the functions and limits of VBA)
Matching the Information to the Proper IDs
Every object has an ID 6 characters long ranging from 000100 to 999999. When taking information from the first sheet, I need to make sure it gets placed back in the row with the right ID in the second sheet (Note there's 1000 rows on the first sheet and 6000 on the second sheet).
Final notes: The IDs are stored as text and not numbers (If they need to change lmk). Both sheet's information are within tables. I'll probably be using this method for other similar sheet 1s. Any conversions (for the what and how) that fail should be marked down as Unknown.
A Visual Representation of the 2 Sheets
Sheet 1 Format
Sheet 2 format
We can create a 2 dimensional array to hold all the pairs of one dictionary, then check against each element using a For..Next loop.
Sub transcribe()
On Error GoTo Handler
Application.ScreenUpdating = False
Dim WS1 As Worksheet, WS2 As Worksheet
Dim ID1 As Range, ID2 As Range
'This is assuming youre working in Sheets 1 and 2
Set WS1 = Sheets(1)
Set WS2 = Sheets(2)
'This is assuming your tables are in these locations
Set ID1 = WS1.Range(WS1.Cells(1, 1), WS1.Cells(10, 1))
Set ID2 = WS2.Range(WS2.Cells(1, 1), WS2.Cells(20, 1))
Dim cellx As Range
Dim rowID1 As Integer
Dim FieldA As String, FieldB As String
Dim IDfound As Boolean
IDfound = True
Dim arrayA(1 To 10, 1) As String
arrayA(1, 0) = "MILPRO : Industrial"
arrayA(1, 1) = "Industrial"
arrayA(2, 0) = "MILPRO : Public Saftey"
arrayA(2, 1) = "Public Saftey"
'... etc. You have to complete this array with all the pairs of your dictionary of Field A
'array(X, 1) holds what you expect to find in table 1, and array(X, 0) holds what you want to write down in table 2.
Dim arrayB(1 To 9, 1) As String
arrayB(1, 0) = "Multi-Door"
arrayB(1, 1) = "Multi-Door"
arrayB(2, 0) = "Distribuitor"
arrayB(2, 1) = "Dealer & Distribuitor"
'... etc. You have to complete this array with all the pairs of your dictionary of Field B
'array(X, 1) holds what you expect to find in table 1, and array(X, 0) holds what you want to write down in table 2.
'Now we sweep each cell in Table 2
For Each cellx In ID2.Cells
'And we search its ID for a match in Table 1.
rowID1 = Application.Match(cellx.Value, ID1, 0)
If IDfound = True Then
'We then write down the values of Field A and B in the found row
FieldA = ID1.Resize(1).Offset(rowID1 - 1, 2).Value
FieldB = ID1.Resize(1).Offset(rowID1 - 1, 3).Value
'And we call a function (see below) to correct their values
cellx.Offset(0, 2).Value = corrected(FieldA, arrayA, 10)
cellx.Offset(0, 3).Value = corrected(FieldB, arrayB, 9)
Else
cellx.Offset(0, 2).Value = "ID not found"
cellx.Offset(0, 3).Value = "ID not found"
IDfound = True
End If
Next
Application.ScreenUpdating = True
Exit Sub
Handler:
IDfound = False
Resume Next
End Sub
Function corrected(Field As String, arrayX As Variant, UB As Integer) As String
'This is the dictionary-like function
Dim found As Boolean
'We sweep each element in the dictionary array until we find a match
For i = 1 To UB
If Field = arrayX(i, 1) Then
corrected = arrayX(i, 0)
found = True
Exit Function
Exit For
End If
Next
'If no match was found, we will write that down in the result
If found = False Then
corrected = Field & " - Not found in dictionary"
Exit Function
End If
'This code should never be reached, its just for foolproofing
corrected = "Error"
End Function

How To Consolidate Multiple Rows Into One Row

My situation is as follows. I have a list of around 2k student accounts and sort the information to a specific format that i can format to our new CRM. The way the data is presented initially makes that problematic.
As you can see on the first screenshot, every student's university choice is presented in a separate row. So if a student has chosen more than one university, data about it is stored in 2-6 rows (each student can select 1 to 6 universities) repeating his personalID, name, forename and DoB every line.
What I need to achieve is to remove repeating information and store all data about each student in one row per student(example on screenshot 2).
I have no idea how to achieve this using VBA. I was trying with IFs, loops and arrays but without any progress. I need help on how to accomplish that using VBA.
Please let me know if you need more information. I will try to explain it in more details if required.
Screenshot 1
Screenshot 2
EDIT: This is the part of the report. I am working on a macro that will format it to our needs and will give us more info about the student's accounts. That is why I am asking for help in VBA.
No need to use VBA for this. Power Query will help you better. Have a look here: https://excelgorilla.com/power-bi/power-query/aggregate-text-values-using-group-by/
This seems to work. I'm new to VBA and programming in general so it's possibly not the most efficient solution and can definitely be improved.
Instead of working with a blank sheet, it transforms the current data to the format you wanted. You can add field headings where you want.
Edit: It assumes that each Student has 5 universities in the list. The code can be adjusted to account for any number by just adjusting the target range dynamically.
Edit 2: I added the change to account for students who've entered any number of universities between 1 to 5. Let me know if this gets it done!
Sub ReArrange_Data()
Dim lrow As Long
lrow = Cells(Rows.Count, 1).End(xlUp).Row
Dim First As Integer
Dim Last As Integer
Dim test As Integer
Dim test1 As Integer
Dim student_range As Range
Dim student_rows As Integer
Dim target_range As Range
First = 2
For i = 2 To lrow
Last = First
If Cells(First, "D").Value = "" Then GoTo Break 'reached end of data
While Cells(Last, "D").Value = Cells(Last + 1, "D").Value
Last = Last + 1
Wend
If Last <> First Then 'check if mulitiple uni and build range
Set student_range = Range("E" & First & ":" & "E" & Last)
student_rows = student_range.Rows.Count
If student_rows = 5 Then
Set target_range = Range("E" & First & ":" & "I" & First)
ElseIf student_rows = 4 Then
Set target_range = Range("E" & First & ":" & "H" & First)
ElseIf student_rows = 3 Then
Set target_range = Range("E" & First & ":" & "G" & First)
ElseIf student_rows = 2 Then
Set target_range = Range("E" & First & ":" & "F" & First)
End If
Else
GoTo Skip 'student entered one uni, go to next loop
End If
target_range = Application.WorksheetFunction.Transpose(student_range.Value) 'row to column
Rows(First + 1 & ":" & Last).EntireRow.Delete
Skip: 'delete repeated entries
First = First + 1
Next i
Break:
End Sub

Paste rows from one sheet to another when condition is met in VBA

I have a macro with all tasks I have to do to generate a report, currently I need merge new data from the new sheet to the original. Some sort of JOIN if we could call it like that.
In the srcWorkbook we have things like address, who was in charge in that time and a date/id timestamp. In the outWorkbook there's vendor personal data and such.
Output table / New data table / Output table (after running macro)
To merge the both sheets I want to match id_date and id_hr in both files so if srcWorkbook and outWorkbook id's match, grab srcWorkbook row and paste it on the side of the outWorkbook.
I've tried to do a for / if statement which reads apparently but it doesn't paste the new rows. I also tried a VLOOKUP but I'd rather stick with basic statements for future modifications.
Sub popularSubG()
'File calling here and index variables
'Cells
' cell Src
Dim cellSrcPerPro As Long
Dim cellSrcIDHR As Long
' cell Out
Dim cellOutPerPro As Long
Dim cellOutIDHR As Long
For indexRowSrc = 2 To indexLastRowSrc
cellSrcPerPro = srcWorkbook.Cells(indexRowSrc, "A").Value
cellSrcIDHR = srcWorkbook.Cells(indexRowSrc, "B").Value
cellOutPerPro = outWorkbook.Cells(indexRowSrc, "A").Value
cellOutIDHR = outWorkbook.Cells(indexRowSrc, "B").Value
If cellSrcPerPro = cellOutPerPro & cellSrcIDHR = cellDestinoIDHR Then
indexRowOut = indexRowOut + 1
srcWorkbook.Sheets(1).Cells(2, "C").EntireRow.Copy Destination:=outWorkbook.Sheets(1).Range("O" & Rows.Count).End(xlUp).Offset(0)
End If
Next indexRowSrc
MsgBox "Sub ended"
End Sub

SAP GUI script: search text in ALV List (ABAP List)

I'm currently creating an automation script where data from Excel will be searched in SAP GUI ALV List. I will be looping to the rows that, if it will match anything in the columns "Assignment", "DocumentNo" and "Quantity" to the "textToFind" in Excel, then I will be able to edit the text for each item matched:
How will I set the table and loop through the rows of the table until I find the text that I'm looking for?
I believe it will also only allow me to search for the visible rows.
I tried to record the steps in SAP GUI but it only gives me this if I position my cursor somewhere in the column "Assignment":
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/lbl[18,15]").setFocus
session.findById("wnd[0]/usr/lbl[18,15]").caretPosition = 10
Which I know that it tells me the current cell address (column 18, row 15).
When I tried to check the table name on "Assignment" field (F1), it gives me the name of "RFPOSXEXT".
Let's assume you display the data in a ALV Grid and you have the session ready as you write in your post. Then the following code will copy the data from SAP into excel. You have to adjust the code according to your needs
Dim wks As Worksheet
Set wks = " your worksheet here ..."
Dim Table As Object
Dim cols As Long
Dim rows As Long
Dim i As Long, j As Long
Set Table = Session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell")
rows = Table.RowCount - 1
cols = Table.ColumnCount - 1
Dim columns As Object
Set columns = Table.ColumnOrder
Dim arrCol() As Variant
ReDim arrCol(cols)
For j = 0 To cols
arrCol(j) = (CStr(columns(j)))
Next
With wks
.Range(.Cells(1, 1), .Cells(1, cols + 1)).Value = arrCol()
End With
For i = 0 To rows
For j = 0 To cols
arrCol(j) = Table.GetCellValue(i, CStr(columns(j)))
Next
With wks
.Range(.Cells(i + 2, 1), .Cells(i + 2, cols + 1)).Value = arrCol()
End With
If i Mod 10 = 0 Then
Table.SetCurrentCell i, CStr(columns(0))
DoEvents
End If
Next
End Sub
The above code will fail if you don't use griv view control. "Session" must be a valid SAP Guisession pointing to FBL3N with the grid view open. In the link I provided above you will see hot to do that.
The screenshot shows an ALV (Grid View) but which is displayed via the "ABAP List" technology. It's not to be confused with the GuiGridView object.
A text in an ABAP List has no "table" or "field" name, whatever it's for representing an ALV or anything else (F1 is helpless). Only the column and row numbers can be used to get the texts or to move the cursor on these texts.
SAP GUI Scripting represents the texts from a screen of type ABAP List as a collection of contiguous GuiLabel, GuiTextField or GuiCheckBox, in the property Children of the GuiUserArea object.
You can loop at them by using this script, which shows all the fields in an ABAP List, and which is taken from this other answer about ABAP List (see that answer for more information):
text = ""
For Each field In session.findById("wnd[0]/usr").Children
text = text & field.CharTop & " " & field.CharLeft & " " & field.Text & " " _
& field.Id & " " & field.Type & chr(10)
Next
msgbox text
NB: here, the ABAP List is in the "window 0".

How to copy specific columns in specific order from one sheet to another?

I need to copy date and time, code and names from a big data sheet, which contains multiple columns. Row counts may differ.
The sequence of actions should be:
Copy the consecutive Range from A3 which is the first active cell through to the data at column AZ - This is a manual selection.
Using the VBA linked Command button start the process of copying data in next sheet:
for example
sheet1.column B = sheet2.column A
sheet2.column B= ""
'empty and data copy is not needed, please just generate the empty row
sheet1.column Y = sheet2.column C
After the copying process is over, clear all data from sheet1
My core problem is the data count for above rows differs every time. I can't find a correct sequence of commands to get these columns in the order I need from sheet1. To add to that, the formatting breaks and the time values are 'stringified', so it can't be reused.
The generated data needs to be exported to another workbook and the copying process is critically important as I do it repeatedly. Locating and copying each column manually every time.
The solution to your problem is of the form f(x) = y where x is the column no. of the source sheet and y is the column number of that very same column on the destination sheet.
f(x) is a simple mapping between a Source column and transformed into a destination column no.
As you still need to define the problem better by including sample data, I'll simply brief you on The 3 steps to resolve your problem.
I hope you know your VBA well enough to encode the steps into the specific VBA code you need to solve this permanently.
Create a sheet as a "ControlPanel" that maps the columns you need.
Assuming your sheets are named appropriately as per the code below.
Kindly do apply your VBA skills and discretion to customize the code below as per your needs.
Public Sub Add_Msng_And_Check_Prev_EmpData()
'' Objective : Check missing employees from the incoming data placed in the Destination_Sheet sheet which is the client's format.
'' The _Source_Sheet sheet is our destination where processed data sits,
'' columns from Destination_Sheet are mapped to specific columns of the _Source_Sheet sheet.
'' Copy the missing emp codes to these mapped columns.
'' Support : myfullnamewithoutspaces#gmail.com
'' Status : Production 14-Dec-2016 10.32 PM
'' Version : 1.0
'' To Do : 10 is the column number on Source_Sheet where the emp code resides
'' Convert this magic number to a generic solution
Dim Src_Sheet, Destination_Sheet As Worksheet
Dim Dest_Sheet_Column_Mapping, Src_Sheet_Column_Location As Range
Set Src_Sheet = Sheets("Source_Sheet")
Set Destination_Sheet = Sheets("Destination_Sheet")
Set Dest_Sheet_Column_Mapping = Sheets("ControlPanel").Range("A2:A60")
Set Src_Sheet_Column_Location = Sheets("ControlPanel").Range("D2:D60")
Dim myMap() As Integer
Dim myRow As Variant
ReDim myMap(Dest_Sheet_Column_Mapping.Count + 1)
'' Map the source_columns to the destination_columns
For Each myRow In Src_Sheet_Column_Location
'' Index corresponds to Source_Sheet column
'' Value at Index to Destination_Sheet
'' for eg: Destination_Sheet.column = myMap(Src_Sheet.column)
myMap(myRow) = Dest_Sheet_Column_Mapping.Cells(myRow, 1).Value
Next myRow
Dim Primary_Key_Not_Null As Collection
Set Primary_Key_Not_Null = New Collection
Dim Master, Src_Sheet_Range, Src_Range As Range
Dim MissingEmployeeCode, LookupValue, tempVar, LookupResult As Variant
Dim LastRow, i, Src_Range_Rows_Count, Src_Sheet_Range_Rows_Count As Integer
'' This is the source of all new entries we need to search for.
Set Src_Sheet_Range = Destination_Sheet.Range(Destination_Sheet.Cells(1, myMap(10)), Destination_Sheet.Cells(Destination_Sheet.Cells(1048576, myMap(10)).End(xlUp).Row, myMap(10)))
Src_Sheet_Range_Rows_Count = Src_Sheet_Range.Rows.Count
'' This is the database of all previous existing entries we need to search against.
Set Src_Range = Src_Sheet.Range(Src_Sheet.Cells(1, 10), Src_Sheet.Cells(Src_Sheet.Cells(1048576, 10).End(xlUp).Row, 10))
Src_Range_Rows_Count = Src_Range.Rows.Count
For i = 3 To Src_Sheet_Range_Rows_Count
'' Skip the blank rows and header at rows 0 to 2
On Error Resume Next
LookupValue = Destination_Sheet.Cells(i, myMap(10)).Value
LookupResult = Application.Match(LookupValue, Src_Range, 0)
If (IsError(LookupResult)) Then
'' To Do : Check for Duplicates within the previously added values
'' LookupValue becomes your missing empcode and i is the row number it's located at
'' The row number i becomes critical when you want to copy the same record that you have just found missing.
Primary_Key_Not_Null.Add i '' LookupValue
'' LookupValue is the actual missing empcode, however we need the row number for the copy operation later
End If
Next i
LastRow = Src_Sheet.Cells(1048576, 10).End(xlUp).Offset(1, 0).Row
Dim FirstRow, LastColumn, j, Src_Range_Columns_Count As Integer
FirstRow = LastRow
''--Phase 3--------------------------------------------------------------------------------------------------
'' Objective : Get and paste data for each missing empcode
With Src_Range
LastColumn = .Cells(1, 1).End(xlToRight).Column
LastRow = Primary_Key_Not_Null.Count + FirstRow
Set Src_Range = .Range(.Cells(1, 1), .Cells(LastRow, LastColumn))
Src_Range_Columns_Count = Src_Range.Columns.Count
For i = FirstRow To LastRow ''FirstRow + 3 '' Commented for Debugging
For j = 1 To Src_Range_Columns_Count '' 59
'' The simple logic is Row Numbers and Column numbers obtained from all the above operations
'' define the cells in the Src_Sheet sheet that we need this data pasted ito.
'' For details please see the code below.
Src_Sheet.Cells(i, j).Value = Destination_Sheet.Cells(Primary_Key_Not_Null(i - FirstRow + 1), myMap(j)).Value
Next j
Next i
End With
''--Phase 4--------------------------------------------------------------------------------------------------
'' Objective : For the previous range in Source_Sheet, check each cell in each column against the mapped columns in the Destination_Sheet.
'' When you find a discrepancy: style it Bad, for the matches: style it Good,
'' for the not found : Style it neutral.
LastRow = FirstRow
FirstRow = 2
Set Src_Range = Src_Sheet.Range(Src_Sheet.Cells(2, 1), Src_Sheet.Cells(LastRow, LastColumn))
Src_Range.Style = "Normal"
Dim FoundRow, FoundColumn As Integer
FoundRow = 0
FoundColumn = 10
Dim LookupRange, LookupDatabase As Range
Set LookupRange = Src_Sheet.Range(Src_Sheet.Cells(1, 10), Src_Sheet.Cells(LastRow, 10))
Set LookupDatabase = Destination_Sheet.Range(Destination_Sheet.Cells(1, myMap(10)), Destination_Sheet.Cells(Src_Sheet_Range_Rows_Count, myMap(10)))
Dim FoundRows As Collection
Set FoundRows = New Collection
'' Locate the row of each employee code on Emp Master, push it into a collection and let the emp code be it's key
Dim LookupRange_Row_Count As Integer
LookupRange_Row_Count = LookupRange.Rows.Count
For i = 2 To LookupRange_Row_Count
On Error Resume Next
FoundRow = Application.Match(LookupRange.Cells(i, 1).Value, LookupDatabase, 0)
If (Not IsError(FoundRow)) Then
'' myRow contains EmpCode which is the key, FoundRow = Where I Found it, becomes the value.
FoundRows.Add FoundRow, CStr(LookupRange.Cells(i, 1).Value)
End If
Next i
Dim Src_Sheet_Value, EmpMstrValue, myEmpCodeString As String
For i = FirstRow To LastRow '' 2 to 1029
For j = 1 To Src_Range_Columns_Count '' 59
'' Handle 4 cases.
'' 1. Src_Sheet Cell Value Found and matches = Good
'' 2. Src_Sheet Cell Value Found and does not match = Bad
'' 3. Src_Sheet Cell Value Not Found or not in Scope and hence does not match = Neutral
'' 4. Src_Sheet Cell Value is a duplicate of a value which is already checked earlier. = ??
Src_Sheet_Value = Src_Sheet.Cells(i, j).Value
myEmpCodeString = CStr(LookupRange.Cells(i, 1).Value)
myRow = CInt(FoundRows(myEmpCodeString))
EmpMstrValue = Destination_Sheet.Cells(myRow, myMap(j)).Value
'' Implements 1. Src_Sheet Cell Value Found and matches = Good
If Src_Sheet_Value = EmpMstrValue Then
Src_Sheet.Cells(i, j).Style = "Good"
Else
Src_Sheet.Cells(i, j).Style = "Bad"
End If
Next j
Next i
End Sub
I found myself in the same situation as yourself sometime back. Although the code is conceptually simple, it requires you to thoroughly define your problem in the Source, Destination, Transformation pattern.
Do Feel free to mail me at myfullnamewithoutspaces#gmail.com. I'll assist any way I can.

Resources