VBA help

pauleverton

New Member
Joined
Feb 8, 2014
Messages
21
Hello,

Sorry for what is probably a really simple question but can't seem to find the answer to what I'm trying to do, although probably misunderstood what I was looking at (very new to VBA)!

All I'm trying to do is loop the below text so that it continues for the whole spreadsheet where there is data in column B

Dim score As Integer, result As String
score = Range("B2").Value
If score >= 6 Then result = "this is great"


Range("H2").Value = result
Selection.Offset(1, 0).Select

I don't know if I need to adjust the range or if it needs looping down the column, bit confused.

If anyone can help that would be much appreciated.

Paul
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Steph77

Board Regular
Joined
Sep 18, 2014
Messages
119
Try this:

Code:
Sub Score()

Dim LastRow As Integer
Dim Counter As Integer

LastRow = Range("B65000").End(xlUp).Row

For Counter = 2 to LastRow

If Range("B" & Counter).Value >= 6 Then Range("H" & Counter) = "This is great"

Next Counter

End Sub
 

pauleverton

New Member
Joined
Feb 8, 2014
Messages
21
Try this:

Code:
Sub Score()

Dim LastRow As Integer
Dim Counter As Integer

LastRow = Range("B65000").End(xlUp).Row

For Counter = 2 to LastRow

If Range("B" & Counter).Value >= 6 Then Range("H" & Counter) = "This is great"

Next Counter

End Sub
Thank you, that's worked perfectly!!!
 

Watch MrExcel Video

Forum statistics

Threads
1,109,522
Messages
5,529,329
Members
409,863
Latest member
stacy09
Top