Selasa, 15 Juli 2014

[ExcelVBA] make a named range with similar values

 

In a column I have several numbers, some the same, sorted increasing.

Starting from one cell (startcell) in the column I want to name a range ("input") consisting of all cells with the same value as the startcell.

Starting on the first "123" I like to name the first 4 cells

I have made a sub, which Works but I suspect it to be not really good VBA.

Is there a more elegant way doing this?

123
123
123
123
456
456
456


Sub laginputrange()
Range("start").Select
Do

ActiveCell.Offset(1, 0).Select
Loop While ActiveCell.Value = Range("Start").Value
ActiveCell.Offset(-1, 0).Name = "slutt"
Range("start", "slutt").Name = "input"
End Sub





regards

Torstein



__._,_.___

Posted by: Torstein Johnsen <sejohnse@yahoo.no>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Yahoo Groups
Control your view and sort preferences per Yahoo Group
You can now control your default Sort & View Preferences for Conversations, Photos and Files in the membership settings page.

----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------

.

__,_._,___

Tidak ada komentar:

Posting Komentar