VBA: Select Rows

VBA: Select Rows

Post by Suzanne Tomczyk - SACA Business x27 » Wed, 13 Apr 1994 09:07:33



I would like to periodically "select" either rows or columns and then
perform some function on them like auto outline.  The problem seems to
be in "selecting" these rows/columns using variables.

For examle

sub selectRows (x as integer, y as integer)
  Rows(x:y).Select
end sub

This does not work, is there a way to do this ?

-st

Also, does anyone have some recommendations on Excel 5.0 reference books
that take you beyond an intermediate level ?

 
 
 

VBA: Select Rows

Post by Keyuan Jia » Wed, 13 Apr 1994 23:46:35




>I would like to periodically "select" either rows or columns and then
>perform some function on them like auto outline.  The problem seems to
>be in "selecting" these rows/columns using variables.

>For examle

>sub selectRows (x as integer, y as integer)
>  Rows(x:y).Select
>end sub

>This does not work, is there a way to do this ?

the correct code should be (assume you use r1c1 reference style)

sub selectRows (x as integer, y as integer)
    Range(Cells(x, 1), Cells(y, 256)).Select
End Sub

rows is a method while range is an _object_ in this case. an object can
have a _method_ (select).

Quote:>Also, does anyone have some recommendations on Excel 5.0 reference books
>that take you beyond an intermediate level ?

I have not seen such a book yet.

hope this helps.

--


 
 
 

VBA: Select Rows

Post by John Walkenba » Thu, 14 Apr 1994 03:07:52



: I would like to periodically "select" either rows or columns and then
: perform some function on them like auto outline.  The problem seems to
: be in "selecting" these rows/columns using variables.

: sub selectRows (x as integer, y as integer)
:   Rows(x:y).Select
: end sub

: This does not work, is there a way to do this ?

Try something like this:

sub selectRows (x as integer, y as integer)
   RowsToSelect = x & ":" & y
   Rows(RowsToSelect).Select
end sub

____________________________________________________________

  John Walkenbach                      San Diego, CA (USA)

____________________________________________________________

 
 
 

1. VBA: Can't select the rows betweeen 2 Range Names (but not including)

Hi,
I have 2 range Names:
ClientDetails is cell A6
SiteDetails is cell A51.

I wish to use this information and Hide/Unhide rows 7:50 but can't
figure out the syntax.

Thanks in advance
Peter

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range,
Cancel As Boolean)
Dim StartRow As String
Dim EndRow As String

If Target.Row = 1 Then
    Rows("2:5").Select

ElseIf Target.Row = Range("ClientDetails").Row Then
    StartRow = Str(Range("ClientDetails").Row + 1)
    EndRow = Str(Range("SiteDetails").Row - 1)
'At this point I can get StartRow = "7" and EndRow = "50"
'but cant get the next line to work.
    Rows("StartRow:EndRow").Select
'    Rows("7:50").Select

Else
    GoTo Continue1
End If

If Selection.EntireRow.Hidden = True Then
    Selection.EntireRow.Hidden = False
Else
    Selection.EntireRow.Hidden = True
End If
ActiveCell.Offset(-1, 0).Range("A1").Select
Cancel = True

Continue1:
End Sub

2. When a link only works one way...

3. VBA code to select a range of rows?

4. Curious as 'Dell' ...

5. : XL5/VBA: Knowing the rows selected with xlFilterInPlace

6. Need VDT font help...

7. select non adjacent rows in vba in excel

8. Office 2000 Install Fails WITH termserv.mst Transform

9. Type mismatch when selecting a row using a variable for the row

10. Getting row data from a selected row?

11. Multiple rows in table but display single row in select statement

12. VBA code to delete row based on vaule of one cell within that row?

13. SELECT FROM t1 WHERE id IN (SELECT id FROM t2 UNION SELECT id