Reputation: 3
I am working on some homework and I can't figure out why my code won't work. The assignment is to request a name then respond in red text in B10.
Here is my code:
Any help would be great- Thanks!
Upvotes: 0
Views: 7025
Reputation: 2284
This error comes from the line With RAnge("b10").Font.ColocarIndex = 3
, With
supose to be used only to objects (not expressions)
sName = Application.InputBox(Prompt:="Please enter your name.", Type:=2)
With Sheets("MyNewSheet").Range("B10")
.Font.ColorIndex = 3
.Value = sName
End With
Upvotes: 1
Reputation: 96753
Consider:
Sub qwerty()
Sheets("MyNewSheet").Activate
With Range("B10")
.Font.ColorIndex = 3
strName = Application.InputBox(Prompt:="Please enter your name.", Type:=2)
.Value = strName
End With
End Sub
Upvotes: 0