ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Quick Question re For and Next (https://www.excelbanter.com/excel-programming/359620-quick-question-re-next.html)

Paige

Quick Question re For and Next
 
Am trying to search through all of the Column E, and if any cell = "SUPPORT"
AND the offset (0,4) to that cell < "", then it should put the word "Note 1"
in the cell's offset (0,5). I keep getting the error message 'Next Without a
For', but I have a 'for' in the code (see below). Can someone please advise
what I'm doing wrong?


With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count, "E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
Next rng


Doug Glancy

Quick Question re For and Next
 
Paige,

You need and EndIf to match your If. Sometimes the messages get a little
mixed up as to which pair of With/End With, For/Next, End/EndIf is missing a
piece.

hth,

Doug

"Paige" wrote in message
...
Am trying to search through all of the Column E, and if any cell =
"SUPPORT"
AND the offset (0,4) to that cell < "", then it should put the word "Note
1"
in the cell's offset (0,5). I keep getting the error message 'Next
Without a
For', but I have a 'for' in the code (see below). Can someone please
advise
what I'm doing wrong?


With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count,
"E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
Next rng




Ardus Petus

Quick Question re For and Next
 
With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count,
"E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
end if
Next rng

Regards,
--
AP

"Paige" a écrit dans le message de
...
Am trying to search through all of the Column E, and if any cell =

"SUPPORT"
AND the offset (0,4) to that cell < "", then it should put the word "Note

1"
in the cell's offset (0,5). I keep getting the error message 'Next

Without a
For', but I have a 'for' in the code (see below). Can someone please

advise
what I'm doing wrong?


With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count,

"E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
Next rng




Tom Ogilvy

Quick Question re For and Next
 
With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count, "E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
end if
Next rng

--
Regards,
Tom Ogilvy

"Paige" wrote:

Am trying to search through all of the Column E, and if any cell = "SUPPORT"
AND the offset (0,4) to that cell < "", then it should put the word "Note 1"
in the cell's offset (0,5). I keep getting the error message 'Next Without a
For', but I have a 'for' in the code (see below). Can someone please advise
what I'm doing wrong?


With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count, "E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
Next rng


Paige

Quick Question re For and Next
 
Darn Darn Darn! I messed around with this for 2 hours. Sometimes I can't
see the forest for the trees. Thanks guys!!!

"Tom Ogilvy" wrote:

With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count, "E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
end if
Next rng

--
Regards,
Tom Ogilvy

"Paige" wrote:

Am trying to search through all of the Column E, and if any cell = "SUPPORT"
AND the offset (0,4) to that cell < "", then it should put the word "Note 1"
in the cell's offset (0,5). I keep getting the error message 'Next Without a
For', but I have a 'for' in the code (see below). Can someone please advise
what I'm doing wrong?


With wks
Set rngToSearch = .Range(.Range("E12"), .Cells(Rows.Count, "E").End(xlUp))
End With
For Each rng In rngToSearch
If rng.Value = "SUPPORT" And rng.Offset(0, 4) < "" Then
rng.Offset(0, 5).Value = "Note 1"
Next rng



All times are GMT +1. The time now is 08:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com