ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to select multiple rows using vba (https://www.excelbanter.com/excel-programming/300470-how-select-multiple-rows-using-vba.html)

almostthere

how to select multiple rows using vba
 
I want to select multiple rows (so I can then sort them)

This is what I have so far:

Do While Worksheets(I).Cells(InputRow, 1).Value < ""
Rows(InputRow).Select
InputRow = InputRow + 1
Loop

But it just highlights the specific row everytime it goes through th
loop and the one that was highlighted is not anymore.

I want to have the rows STAY highlighted after it goes through th
loop.

Thanks:

--
Message posted from http://www.ExcelForum.com


pikus

how to select multiple rows using vba
 
Are you SURE you want to select all those rows? I ask because, wit
VERY few exceptions, it is just as effective and MUCH faster to do th
same job without selecting anything at all. If you post a little mor
detail about what you're trying to accomplish maybe we could make som
suggestions about how you're going about it. - Piku

--
Message posted from http://www.ExcelForum.com


Chip Pearson

how to select multiple rows using vba
 
Try something like

Do While Worksheets(I).Cells(InputRow, 1).Value < ""
Range(Cells(1, 1), Cells(InputRow, 1)).EntireRow.Select
InputRow = InputRow + 1
Loop


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"almostthere " wrote
in message ...
I want to select multiple rows (so I can then sort them)

This is what I have so far:

Do While Worksheets(I).Cells(InputRow, 1).Value < ""
Rows(InputRow).Select
InputRow = InputRow + 1
Loop

But it just highlights the specific row everytime it goes

through the
loop and the one that was highlighted is not anymore.

I want to have the rows STAY highlighted after it goes through

the
loop.

Thanks:)


---
Message posted from http://www.ExcelForum.com/




almostthere[_3_]

how to select multiple rows using vba
 
Well I am trying to find a way to sort a certain number of cells
alphabetically. Selecting the rows, then sorting them is the only wa
I could think of doing it.

For example say i have this

Row 34: Burkom, Diane
Row 35: Hartford, Pamela
Row 36: Adrian, Steve
Row 37: (Blank)

InputRow currently has the value 34, and so I want to be able to onl
sort rows 34 through 36.

Make better sense? Please let me know. Thanks

Cheer

--
Message posted from http://www.ExcelForum.com


almostthere[_2_]

how to select multiple rows using vba
 
Oh and there are various columns to each row, containing number of hour
worked for each across the number of months

--
Message posted from http://www.ExcelForum.com


almostthere[_4_]

how to select multiple rows using vba
 
Chip Pearson wrote:
[b]Try something like

Do While Worksheets(I).Cells(InputRow, 1).Value < ""
Range(Cells(1, 1), Cells(InputRow, 1)).EntireRow.Select
InputRow = InputRow + 1
Loop



Worked Great!!!:cool: Thanks:

--
Message posted from http://www.ExcelForum.com


almostthere[_5_]

how to select multiple rows using vba
 
I had a little trouble with that code because it would highlight all o
the rows above InputRow. So what I did was create another variabl
("InputRow2") and did not change that variable in the loop. Jus
posting this in case someone else is has same question.

Dim InputRow As Integer
Dim InputRow2 As Integer
InputRow = 55
InputRow2 = InputRow

Do While Worksheets("Summary").Cells(InputRow, 1).Value < ""
Range(Cells(InputRow2, 1), Cells(InputRow, 1)).EntireRow.Select
InputRow = InputRow + 1
Loop
End Su

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:23 PM.

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