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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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
 
Upvote 0
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!!!
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,184
Members
448,554
Latest member
Gleisner2

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
Back
Top