Guys,
Got something working somehow by re purposing the bits of code.
I have got a defined excel table "tbl_data" with columns "Name" and "Desc"
Based on Names entered, I am creating few excel sheets.
I have got bit of code which checks for duplicates in column "Name" and highlights those cells.
From the code what I understand is, each cell is being checked (of course it should).
I am looking to find a solution for, disabling the button if there is duplicates.
I tried using btn.enabled= false, but as use moves to next row for entering the data, the button is enabled back.
coz I am putting the btn.enabled = true in "else" block.
Need your expertise here.
Got something working somehow by re purposing the bits of code.
I have got a defined excel table "tbl_data" with columns "Name" and "Desc"
Based on Names entered, I am creating few excel sheets.
I have got bit of code which checks for duplicates in column "Name" and highlights those cells.
From the code what I understand is, each cell is being checked (of course it should).
I am looking to find a solution for, disabling the button if there is duplicates.
I tried using btn.enabled= false, but as use moves to next row for entering the data, the button is enabled back.
coz I am putting the btn.enabled = true in "else" block.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myRange As Range
Dim i As Integer
Dim j As Integer
Dim myCell As Range
Set myRange = Range("tbl_data[Name]")
For Each myCell In myRange
If WorksheetFunction.CountIf(myRange, myCell.Value) > 1 Then
myCell.Interior.ColorIndex = 3
btn_create.Enabled = False
Else
myCell.Interior.ColorIndex = 0
btn_create.Enabled = True
End If
Next
End Sub
Need your expertise here.