View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] benmcclave@gmail.com is offline
external usenet poster
 
Posts: 29
Default Error 400 in VB editor

Howard,

I can't seem to duplicate the error, so I'm not sure if this will help. However, it could be that CTRL+c (or CTRL+v)has been inadvertently assigned to one of your macros, causing it to run when you are not expecting it to.

I could not find any reason why the code you posted would cause the inputbox to remain open, so perhaps another piece of code (such as the AllInCell sub that this code calls) is the culprit.

Since it looks like AllInCell is just concatenating all of the X's and O's, I think you could eliminate the other routine altogether. The sub I wrote below will build the X's, O's and spaces and place the result in cell A2. Hope it helps.

-Ben

Sub XandO()

Dim j As Integer
Dim c As Range
Dim CName As String
j = Range("AB1").End(xlToLeft).Column

CName = InputBox("Enter a duplicated leter in AB4", "Donkey Letter")
If CName = vbNullString Then Exit Sub
Range("AB4") = CName
CName = vbNullString

For Each c In Range("A1").Resize(1, j)
Select Case c.Value
Case Is = Range("AB4").Value
CName = CName & "O"
Case Is = vbNullString
CName = CName & " "
Case Else
CName = CName & "X"
End Select
Next

Range("A2").Value = CName ' This puts all the X O,s into one cell

Range("A1").Resize(1, j).ClearContents
Range("A1").Select

End Sub