VBA help

pauleverton

New Member
Joined
Feb 8, 2014
Messages
23
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
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

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
23
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!!!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,627
Messages
5,838,444
Members
430,548
Latest member
hh_dh2001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top