Option Explicit
Sub x()
Dim IsJournalEntry As Variant
Set IsJournalEntry = Cells.Find(What:="Hello World", After:=Cells(1, 1), MatchCase:=False)
If Not IsJournalEntry Is Nothing Then
Range("A1").Value = 1000
Else
Range("A2").Value = 2000
End If
End Sub
1. You declared Counter as an integer but you assigned a string to it when you put quotes around "1" making VBA convert it to an integer.
2. Notice the space: If IsJournal Entry = "Hello World"
3. Your If is missing a THEN
If IsJournalEntry = "Hello World" Then
It should look like:
Option Explicit
Sub x()
Dim Counter As Integer
Dim IsJournalEntry As Variant
Counter = 1
For Counter = 1 To 5
Set IsJournalEntry = Cells.Find(What:="Hello World", After:=Cells(1, 1), MatchCase:=False)
IsJournalEntry = ActiveCell.Value
If IsJournalEntry = "Hello World" Then
Range("A1") = 1000
Else
Range("A2") = "2000"
End If
Counter = Counter + 1
Next
End Sub
Bookmarks