ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting text (https://www.excelbanter.com/excel-programming/332624-selecting-text.html)

Steve

Selecting text
 
I'm new to programming. i have a sheet that rows will keep being added in as
we get more jobs. i created a button to sort the data. i need code to tell
the button to select all the data, even after more has been added.

also, what would be the easiest code to tell a button to add a row for new
entry...

thank you

Steve

Selecting text
 
or if i can avoid selecting all together, i trust you guys for the better
method


"steve" wrote:

I'm new to programming. i have a sheet that rows will keep being added in as
we get more jobs. i created a button to sort the data. i need code to tell
the button to select all the data, even after more has been added.

also, what would be the easiest code to tell a button to add a row for new
entry...

thank you


Dave Peterson[_5_]

Selecting text
 
Depending on what your data looks like, you might get away with just sorting the
whole column:

With ActiveSheet.Columns("A:F")
.Cells.Sort Key1:=.Columns(1), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End With

Or if you can pick out a column that always has data in it when that row is
used:

Dim LastRow as long

with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
with .range("a1:F" & lastrow)
.cells.sort .....
end with
end with

=====
And one more option. Use a dynamic range that expands or contracts when you
insert/delete a row.

Take a look at Debra Dalgleish's site to read more about it:
http://www.contextures.com/xlNames01.html#Dynamic


Then you can use that in your code:

with worksheets("sheet1").range("yourrangenamehere")
.cells.sort ....
end with

steve wrote:

I'm new to programming. i have a sheet that rows will keep being added in as
we get more jobs. i created a button to sort the data. i need code to tell
the button to select all the data, even after more has been added.

also, what would be the easiest code to tell a button to add a row for new
entry...

thank you


--

Dave Peterson


All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com