unknownymous
Board Regular
- Joined
- Sep 19, 2017
- Messages
- 249
- Office Version
- 2016
- Platform
- Windows
Hi Gurus,
Good day!
I was looking for some codes on how to create a prompt if the data is not the same.
I saw this which is workable but I need to apply the condition that if the cell is blank, it should ignore it:
=========================================================
"= Existing Code from Source: VBA code - check if cells in range contain same value
Sub vv()
Dim rng As Range, v, cel As Range, x%
Set rng = Selection 'Change range as required
v = rng(1)
For Each cel In rng
If cel <> v Then
x = 1
Exit For
End If
Next
If x = 0 Then
'next step
Else: MsgBox "Not same"
End If
End Sub
=========================================================
Sample data:
Here: The macro should prompt and detect that the data is not the same for Title & Country Columns. Blank cells should be ignored.
Appreciate the help.
Cheers!
Good day!
I was looking for some codes on how to create a prompt if the data is not the same.
I saw this which is workable but I need to apply the condition that if the cell is blank, it should ignore it:
=========================================================
"= Existing Code from Source: VBA code - check if cells in range contain same value
Sub vv()
Dim rng As Range, v, cel As Range, x%
Set rng = Selection 'Change range as required
v = rng(1)
For Each cel In rng
If cel <> v Then
x = 1
Exit For
End If
Next
If x = 0 Then
'next step
Else: MsgBox "Not same"
End If
End Sub
=========================================================
Sample data:
Title | Name | Country | |
001 | Marcus | AUS | |
002 | Sean | US | |
001 | Melody | AUS |
Here: The macro should prompt and detect that the data is not the same for Title & Country Columns. Blank cells should be ignored.
Appreciate the help.
Cheers!