ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Range.Select Using Variables - need syntax (https://www.excelbanter.com/excel-discussion-misc-queries/13352-range-select-using-variables-need-syntax.html)

gradientS

Range.Select Using Variables - need syntax
 

Dim firstrowOLD As Long
Dim lastrowOLD As Long

Cells.Find(What:="Text1", -etc-)

firstrowOLD = ActiveCell.Row

Cells.Find(What:="Text2", -etc-)

lastrowOLD = ActiveCell.Row

-need correct syntax for next line-

Range("H" & firstrowOLD : "I" & lastrowOLD).Select

-I get a Compile error: Expected List Seperator at the colon-
-not sure how this is different from Range("H25:I30").Select-


--
gradientS
------------------------------------------------------------------------
gradientS's Profile: http://www.excelforum.com/member.php...o&userid=16563
View this thread: http://www.excelforum.com/showthread...hreadid=345829


HiArt


Range("H" & firstrowOLD & ":I" & lastrowOLD).Select

i.e. the quotes just before the "I" were in the wrong place.

HTH

Art


--
HiArt
------------------------------------------------------------------------
HiArt's Profile: http://www.excelforum.com/member.php...o&userid=19953
View this thread: http://www.excelforum.com/showthread...hreadid=345829


gradientS


ahhhhh.... Thank you


--
gradientS
------------------------------------------------------------------------
gradientS's Profile: http://www.excelforum.com/member.php...o&userid=16563
View this thread: http://www.excelforum.com/showthread...hreadid=345829


Jim May

When I enter your code (for testing) the following line
shows IN RED - indicating bad syntax:
Cells.Find(What:="Text1", -etc-)
Even removing the etc and retrying as
Cells.Find(What:="Text1")
DOESN't Work,
What do I need to do to move forward?
TIA,


"gradientS" wrote in message
...

Dim firstrowOLD As Long
Dim lastrowOLD As Long

Cells.Find(What:="Text1", -etc-)

firstrowOLD = ActiveCell.Row

Cells.Find(What:="Text2", -etc-)

lastrowOLD = ActiveCell.Row

-need correct syntax for next line-

Range("H" & firstrowOLD : "I" & lastrowOLD).Select

-I get a Compile error: Expected List Seperator at the colon-
-not sure how this is different from Range("H25:I30").Select-


--
gradientS
------------------------------------------------------------------------
gradientS's Profile:

http://www.excelforum.com/member.php...o&userid=16563
View this thread: http://www.excelforum.com/showthread...hreadid=345829





All times are GMT +1. The time now is 11:31 AM.

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