The following VBA script runs okay but when I click in a cell afterwards excel does not respond and I have to use <CTRL+ALT+DEL> to close excel. Can anybody help me please, I am new to VBA code. I am using Excel 2010. Sub Random_Name()
Dim rNum, gName, DupYN
Dim rng2 As Range
Dim rng As Range
Set rng = Range("B:B")
Set rng2 = Range("C2:C81")
rng2 = ""
For Each cell In rng
cell.Select
here:
rNum = Int((80 - 1 + 1) * Rnd + 1)
gName = Application.VLookup(rNum, Range("A2:B148"), 2, False)
DupYN = Application.WorksheetFunction. _
CountIf(Range("C2:C81"), gName)
If DupYN = 1 Or ActiveCell.Value = gName Then
GoTo here
Else
ActiveCell.Offset(0, 1).Value = gName
End If
End Sub
Dim rNum, gName, DupYN
Dim rng2 As Range
Dim rng As Range
Set rng = Range("B:B")
Set rng2 = Range("C2:C81")
rng2 = ""
For Each cell In rng
cell.Select
here:
rNum = Int((80 - 1 + 1) * Rnd + 1)
gName = Application.VLookup(rNum, Range("A2:B148"), 2, False)
DupYN = Application.WorksheetFunction. _
CountIf(Range("C2:C81"), gName)
If DupYN = 1 Or ActiveCell.Value = gName Then
GoTo here
Else
ActiveCell.Offset(0, 1).Value = gName
End If
End Sub