Remaining Numbers from a List that are not used

  • Thread starter Thread starter Lorence
  • Start date Start date
L

Lorence

Say I have in the following cells

A1 134
A2 567
A3 368

I want C5 to show the remaining numbers from the list of
1,2,3,4,5,6,7,8,9
i.e. 2, 9

This required over approx 25 groups of cells in a sheet


Anyone done this before?

I am not good at VBA, but can manage most Excel functions happily

Lorence
 
Lorence,

Try:
Sub Mytest()
Dim L As String, TestST As String
Dim X, Y
TestST = "123456789"
L = Range("A1").Text & Range("A2").Text & Range("A3").Text
For X = 1 To 9
Y = 1
Do

If Mid(L, X, 1) = Mid(TestST, Y, 1) Then _
TestST = Left(TestST, Y - 1) & Right(TestST, Len(TestST) - Y)
Y = Y + 1
Loop Until Y > Len(TestST)
Next X
Range("C5").Value = TestST
End Sub


Henry
 
Lorence,

Try:
Sub Mytest()
Dim L As String, TestST As String
Dim X, Y
TestST = "123456789"
L = Range("A1").Text & Range("A2").Text & Range("A3").Text
For X = 1 To 9
Y = 1
Do

If Mid(L, X, 1) = Mid(TestST, Y, 1) Then _
TestST = Left(TestST, Y - 1) & Right(TestST, Len(TestST) - Y)
Y = Y + 1
Loop Until Y > Len(TestST)
Next X
Range("C5").Value = TestST
End Sub


Henry

Works brilliantly - thks

Lorence
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top