Does anyone know how to select a range of cells in vba?
Printable View
Does anyone know how to select a range of cells in vba?
Here's one way:
Note that ideally you should specify the sheet too, eg:Code:Range("A3:B7").Select
Code:Sheet1.Range("A3:B7").Select
A table in ms wordQuote:
Originally Posted by si_the_geek
unless you want to display that selection to the user, is is best to work with the data in that cell, by address and avoid using selection
to answer the original question
Documents(1).Tables(1).Rows(2).Select
wouldn't that just select the second row?Quote:
Originally Posted by westconn1
I want to select a range of rows like row 2 through 5 for example
I've searched alot on the web for an answer already so I won't be surprised if this is impossible to do in ms word tables.:eek2:
Many ways to do that:
orCode:With ActiveDocument
.Range(Start:=.Tables(1).Rows(2).Range.Start, _
End:=.Tables(1).Rows(5).Range.End).Select
End With
Code:ActiveDocument.Tables(1).Rows(2).Range.Select
Selection.MoveEnd Unit:=wdRow, Count:=3
Thank you for the help. I will try that.Quote:
Originally Posted by anhn