ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Problem? (https://www.excelbanter.com/excel-programming/374896-simple-problem.html)

Ed[_30_]

Simple Problem?
 
I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?





Allllen

Simple Problem?
 
This works. You should be able to figure it out from this. Lose the colon.

Sub animals()

frog = "B"
cow = "1"
horse = "C"
sheep = 6

Range((frog & cow), (horse & sheep)).Select

End Sub
--
Allllen


"Ed" wrote:

I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?






[email protected]

Simple Problem?
 
Put everything inside a string. In your example, the quotes and
parenthesis are all out of place, and you aren't putting the colon
within the string.

For example, using your example, try this:

dim r as string
r = "f" + cstr (c.row) + ":" + "f" + cstr (tendr)

call activesheet.range (r).select

Hope this helps,
Dom



Ed wrote:
I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?



Dave Peterson

Simple Problem?
 
One mo

range(cells(c.row,"F"),cells(tendr,"F")).activate



Ed wrote:

I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?


--

Dave Peterson

Ed[_30_]

Simple Problem?
 
Thanks, Dom for your help. Works great. I really struggled with it before
posting.


wrote in message
oups.com...
Put everything inside a string. In your example, the quotes and
parenthesis are all out of place, and you aren't putting the colon
within the string.

For example, using your example, try this:

dim r as string
r = "f" + cstr (c.row) + ":" + "f" + cstr (tendr)

call activesheet.range (r).select

Hope this helps,
Dom



Ed wrote:
I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?





[email protected]

Simple Problem?
 
This is one of the cool things about newsgroups. I never knew that the
following would work:

1. range ("A1", "C1") -- I thought the colon was needed.
2. range (cells (1, "A"), cells(2, "A") -- I thought CELLS needed long
arguments.


Dom


Ed wrote:
I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?



Dave Peterson

Simple Problem?
 
#2. Nope. Excel/VBA will work nicely with longs or strings in that column
field.

Range("a1:C1") would need the colon.


" wrote:

This is one of the cool things about newsgroups. I never knew that the
following would work:

1. range ("A1", "C1") -- I thought the colon was needed.
2. range (cells (1, "A"), cells(2, "A") -- I thought CELLS needed long
arguments.

Dom

Ed wrote:
I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?


--

Dave Peterson

Ed[_30_]

Simple Problem?
 
My thanks to Dave also. Newsgroups are great - nearly always learn something
new after I post.

"Dave Peterson" wrote in message
...
#2. Nope. Excel/VBA will work nicely with longs or strings in that
column
field.

Range("a1:C1") would need the colon.


" wrote:

This is one of the cool things about newsgroups. I never knew that the
following would work:

1. range ("A1", "C1") -- I thought the colon was needed.
2. range (cells (1, "A"), cells(2, "A") -- I thought CELLS needed long
arguments.

Dom

Ed wrote:
I need to activate a range using some variables - like so:
range("("f" & c.row):("f" & tendr)").Activate

I've tried every combination I can think of, over and over again, but
nothing I can come up with will work. Can someone help me, please?


--

Dave Peterson





All times are GMT +1. The time now is 02:58 PM.

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