Below is my code:
Sub yenilikleri_ekle()
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long, rng As Range
Set sh1 = ThisWorkbook.Worksheets("Input")
Set sh2 = ThisWorkbook.Worksheets("Ayarlar")
lr = sh1.Cells(Rows.Count, 2).End(xlUp).Row
Set rng = sh1.Range("B5:B" & lr)
For Each c In rng
If WorksheetFunction.CountIf(sh2.Range("A:A"), c.Value) = 0 Then
sh2.Range("A" & sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1) = c.Value
End If
Next
End Sub
What it does is matching cells in sh1
and sh2
. If it's not in sh2
it adds the Cell.Value
to sh2
. The code is working fine until the cell has a text more then 255 chars. (Until it's a long text)
When the text is long, it returns an error "Run-time error 1004: Unable to get countif property of the worksheet"
which comes as nonsense to me. I couldn't fix the problem for 2 days and need your help. I added Dim
for c
but no change, still same error. I changed to CountA
but it then became unresponsive.
Thanks in advance for your help.