Selection of multiple cell within range in VBA?

azusa_329

New Member
Joined
Jun 21, 2017
Messages
1
Hello i am a very VBA newbie and i wonder if it is
possible to select multiple cells that contains more than 0? ( Range("A1").Value > 0)
and if its not move to the next cell until it find the cell have value
more than 1
can i ask what kind of statement and function that i must learn? Thank you very much.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Here is an example of what your code should look like

Code:
Option Explicit


Sub foo()
    Dim i As Long, lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row    'Looks for last item in Column A
    For i = 2 To lr    'sets loop
        If Range("A" & i) > 0 Then
            'Do something if line above is true, otherwise go to next line
        End If
    Next i    'sets up next item in loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

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