I need your help, I have the code below:
And what i want to do is:
--Worksheet "A" Column A: (A1)-Alfred (A2)-Charles
--Worksheet "A" Column F: (F1)-Sweden (F2)- France (So the cell value with "France" on the column F is highlighted because is different on Worksheet "B" Column H for Column A with the cell value "Charles")
--Worksheet "B" Column A: (A1)-Alfred (A2)-Charles
--Worksheet "B" Column H: (H1)-Sweden (H2)-Spain
Is not working, can you help me what is wrong?
I want this macro runs automatically on the worksheet "A", if should be Private Sub how to do to run automatically?
Sub missingvalue()
Application.ScreenUpdating = False
Dim desWS As Worksheet, srcWS As Worksheet
Dim strfind As String
Dim LastRow As Long, lngRow As Long, lngDest As Long
Set srcWS = Sheets("Sheet B")
Set desWS = Sheets("Sheet A")
LastRow = srcWS.Range("A1").End(xlDown).Row
For lngRow = 2 To LastRow
strfind = srcWS.Cells(lngRow, 1)
If Not desWS.Columns(1).Find(what:=strfind, lookat:=xlWhole) Is Nothing Then
lngDest = desWS.Columns(1).Find(what:=strfind, lookat:=xlWhole).Row
End If
If desWS.Cells(lngDest, 6).Value <> srcWS.Cells(lngRow, 8).Value Then
desWS.Cells(lngDest, 6).Interior.Color = vbRed
End If
Next lngRow
Application.ScreenUpdating = True
End Sub
And what i want to do is:
--Worksheet "A" Column A: (A1)-Alfred (A2)-Charles
--Worksheet "A" Column F: (F1)-Sweden (F2)- France (So the cell value with "France" on the column F is highlighted because is different on Worksheet "B" Column H for Column A with the cell value "Charles")
--Worksheet "B" Column A: (A1)-Alfred (A2)-Charles
--Worksheet "B" Column H: (H1)-Sweden (H2)-Spain
Is not working, can you help me what is wrong?
I want this macro runs automatically on the worksheet "A", if should be Private Sub how to do to run automatically?
Sub missingvalue()
Application.ScreenUpdating = False
Dim desWS As Worksheet, srcWS As Worksheet
Dim strfind As String
Dim LastRow As Long, lngRow As Long, lngDest As Long
Set srcWS = Sheets("Sheet B")
Set desWS = Sheets("Sheet A")
LastRow = srcWS.Range("A1").End(xlDown).Row
For lngRow = 2 To LastRow
strfind = srcWS.Cells(lngRow, 1)
If Not desWS.Columns(1).Find(what:=strfind, lookat:=xlWhole) Is Nothing Then
lngDest = desWS.Columns(1).Find(what:=strfind, lookat:=xlWhole).Row
End If
If desWS.Cells(lngDest, 6).Value <> srcWS.Cells(lngRow, 8).Value Then
desWS.Cells(lngDest, 6).Interior.Color = vbRed
End If
Next lngRow
Application.ScreenUpdating = True
End Sub