LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default selecting rows using a variable.

Nick, Good Morning From the Land of the Midnight Sun,
Here A little bit of code I believe will get to job done for ya.

enjoy, Rick (Fairbanks, AK)

Sub testme()
Dim rngBB As Range, rngFound As Range
Dim rngAA As Range
Dim x1 As Integer, x2 As Integer

Set rngBB = Range("B:B")
Set rngAA = Range("A:A")

Set rngFound = rngBB.Find(What:="miscellaneous", LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=
_
xlNext, MatchCase:=False)

If Not rngFound Is Nothing Then
x1 = rngFound.Row
Else
MsgBox ("miscellaneous not found")
Exit sub
End If

Set rngFound = Nothing
Set rngFound = rngAA.Find(What:="ms totals", LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)

If Not rngFound Is Nothing Then
x2 = rngFound.Row
Else
MsgBox ("ms total not found")
Exit Sub
End If

Range(x1 & ":" & x2).EntireRow.Select
End Sub




"cherrynich" wrote in message
...
I have this code...
Dim x1 As Integer
Dim x2 As Integer
Dim x3 As Integer
Columns("B:B").Select

Selection.Find(What:="miscellaneous", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,

SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
x1 = ActiveCell.Row
Columns("A:A").Select

Selection.Find(What:="ms totals", After:=ActiveCell,

LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
x2 = ActiveCell.Row
x3 = (x1:x2)

Rows(x3).Select

With this I am attempting to extract a few rows. I search for
"Miscellaneous" in column B, save the row number as x1. Search for "ms
totals" in column A, saving the row number as x2. All I want to do is

Select
the Rows between those two numbers, seems easy probably is. I will be

very
grateful to anyone who can help me at all, thanks a lot.
Nick Cherry



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting variable rows in a macro that creates a pivot table amarch00 Excel Programming 1 May 12th 05 03:43 PM
selecting range of cells - variable # of rows [email protected] Excel Programming 6 April 15th 05 02:10 PM
Selecting Variable Rows Matt D. Excel Programming 3 June 18th 04 07:22 PM
Selecting a row with a variable ? Blewyn[_6_] Excel Programming 3 April 20th 04 08:16 AM
Selecting rows with variable Jim[_24_] Excel Programming 7 September 16th 03 02:03 PM


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"