|
-
Oct 29th, 2008, 06:26 PM
#1
Thread Starter
New Member
select a range in a table
Does anyone know how to select a range of cells in vba?
-
Oct 29th, 2008, 06:34 PM
#2
Re: select a range in a table
Here's one way:
Code:
Range("A3:B7").Select
Note that ideally you should specify the sheet too, eg:
Code:
Sheet1.Range("A3:B7").Select
-
Oct 29th, 2008, 06:36 PM
#3
Thread Starter
New Member
Re: select a range in a table
 Originally Posted by si_the_geek
Here's one way:
Code:
Range("A3:B7").Select
Note that ideally you should specify the sheet too, eg:
Code:
Sheet1.Range("A3:B7").Select
A table in ms word
-
Oct 29th, 2008, 09:36 PM
#4
Re: select a range in a table
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 30th, 2008, 03:39 AM
#5
Re: select a range in a table
to answer the original question
Documents(1).Tables(1).Rows(2).Select
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 30th, 2008, 03:58 PM
#6
Thread Starter
New Member
Re: select a range in a table
 Originally Posted by westconn1
to answer the original question
Documents(1).Tables(1).Rows(2).Select
wouldn't that just select the second row?
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.
-
Oct 30th, 2008, 04:46 PM
#7
Re: select a range in a table
Many ways to do that:
Code:
With ActiveDocument
.Range(Start:=.Tables(1).Rows(2).Range.Start, _
End:=.Tables(1).Rows(5).Range.End).Select
End With
or
Code:
ActiveDocument.Tables(1).Rows(2).Range.Select
Selection.MoveEnd Unit:=wdRow, Count:=3
-
Oct 30th, 2008, 06:45 PM
#8
Thread Starter
New Member
Re: select a range in a table
 Originally Posted by anhn
Many ways to do that:
Code:
With ActiveDocument
.Range(Start:=.Tables(1).Rows(2).Range.Start, _
End:=.Tables(1).Rows(5).Range.End).Select
End With
or
Code:
ActiveDocument.Tables(1).Rows(2).Range.Select
Selection.MoveEnd Unit:=wdRow, Count:=3
Thank you for the help. I will try that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|