ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Relative cell ranges (https://www.excelbanter.com/excel-programming/327526-relative-cell-ranges.html)

edm[_2_]

Relative cell ranges
 
Hi

In the "Range("A5:E5").Select" statement I need to make the A5:E5 part
of it change as to whatever the active cell is at the time. I have no
idea as to what it will be before hand. Can anyone help me?

Erle


Bob Phillips[_6_]

Relative cell ranges
 
Activecell.Resize(,5).Select

--

HTH

RP
(remove nothere from the email address if mailing direct)


"edm" wrote in message
ups.com...
Hi

In the "Range("A5:E5").Select" statement I need to make the A5:E5 part
of it change as to whatever the active cell is at the time. I have no
idea as to what it will be before hand. Can anyone help me?

Erle




mexage

Relative cell ranges
 
This might help, please tell me if it does or if it doesn't:

....
Dim r as Range
Dim s as String

s=ActiveCell.Value
For Each r in Range("A5:E5")
r.Value=s
Next r

....

That should set the active cell value to the range "A5:E5"

"edm" wrote:

Hi

In the "Range("A5:E5").Select" statement I need to make the A5:E5 part
of it change as to whatever the active cell is at the time. I have no
idea as to what it will be before hand. Can anyone help me?

Erle



David

Relative cell ranges
 
Hi,

These do different things, depends on what you really wnt to do.

Sub Macro1()
ActiveCell.Range("A1:E1").Select
End Sub
(Selects from activecell right to include five cells)

Sub Macro2()
Selection.CurrentRegion.Select
End Sub
(Selects the active "Region")

Thanks,

"edm" wrote:

Hi

In the "Range("A5:E5").Select" statement I need to make the A5:E5 part
of it change as to whatever the active cell is at the time. I have no
idea as to what it will be before hand. Can anyone help me?

Erle



edm[_2_]

Relative cell ranges
 
Thanks for your answer(s). I think I didn't make clear that the A5:E5
needs to change, it could be A23:E23 or A234:E234 or even L512:P512.

Thanks again
Erle


Bob Phillips[_6_]

Relative cell ranges
 
did u c my reply?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"edm" wrote in message
oups.com...
Thanks for your answer(s). I think I didn't make clear that the A5:E5
needs to change, it could be A23:E23 or A234:E234 or even L512:P512.

Thanks again
Erle





All times are GMT +1. The time now is 05:26 AM.

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