Select Rows With Value

IoanZ

Board Regular
Joined
Mar 2, 2018
Messages
50
Hello to everyone
I have this situation
In Range(A1:A6) i put some values.

My activecell is A7.

I want to know which is vba code to select Cells from the top rows of activecell(including activecell) until i find a blank row.

As result Range(A3:A7) will be selected.

Thank's a lot


Row/CollABCD
165
2
335
460
585
621
7
8
9

<tbody>
</tbody>
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

IoanZ

Board Regular
Joined
Mar 2, 2018
Messages
50
Resolved With this
Sub AutoSUM()
Range("A" & ActiveCell.Row).Select ' activecell below the range of numbers
Range("B" & ActiveCell.Row).Value = "x"
Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
Cells(Range("B150").End(xlUp).Row, 1) = Application.WorksheetFunction.Sum(Selection)
Cells(Range("B150").End(xlUp).Row, 2).ClearContents
End Sub
 

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
2,006
This will do as you ask
Code:
Range(ActiveCell, ActiveCell.Offset(-1).End(xlUp)).Select
 

Forum statistics

Threads
1,136,317
Messages
5,675,042
Members
419,546
Latest member
RobWayCot

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