ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Question (https://www.excelbanter.com/excel-discussion-misc-queries/221035-vba-question.html)

peyman

VBA Question
 
hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.

Gary''s Student

VBA Question
 
Sub ordinate()
n = ActiveCell.Row - 1
Range("A" & n & ":F" & n).Select
End Sub

--
Gary''s Student - gsnu200833


"peyman" wrote:

hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.


peyman

VBA Question
 

thanx Gary for your prompt reply.I'll try that
"Gary''s Student" wrote:

Sub ordinate()
n = ActiveCell.Row - 1
Range("A" & n & ":F" & n).Select
End Sub

--
Gary''s Student - gsnu200833


"peyman" wrote:

hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.


peyman

VBA Question
 

it works well. Thanks again
"Gary''s Student" wrote:

Sub ordinate()
n = ActiveCell.Row - 1
Range("A" & n & ":F" & n).Select
End Sub

--
Gary''s Student - gsnu200833


"peyman" wrote:

hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.


Mike H

VBA Question
 
Hi,

If I've understood correctly then try this

Range("A" & ActiveCell.Row - 1 & ":F" & ActiveCell.Row - 1).Select

Mike

"peyman" wrote:

hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.


peyman

VBA Question
 
yes Mike this works too.Thanks

"Mike H" wrote:

Hi,

If I've understood correctly then try this

Range("A" & ActiveCell.Row - 1 & ":F" & ActiveCell.Row - 1).Select

Mike

"peyman" wrote:

hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.


Mike H

VBA Question
 
Your welcome


"peyman" wrote:

yes Mike this works too.Thanks

"Mike H" wrote:

Hi,

If I've understood correctly then try this

Range("A" & ActiveCell.Row - 1 & ":F" & ActiveCell.Row - 1).Select

Mike

"peyman" wrote:

hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.


Shane Devenshire[_2_]

VBA Question
 
Hi,

Here is another way:

ActiveCell.Offset(-1, -3).Resize(, 6).Select

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"peyman" wrote:

hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is D3
the range will be selected like A2:F2.
Thanks for your help.


Rick Rothstein

VBA Question
 
Here is yet another way...

Range("A1:F1").Offset(ActiveCell.Row - 2).Select

--
Rick (MVP - Excel)


"peyman" wrote in message
...
hi,
How can I write a code in a way to select the range A to F columns one row
less than active cell row no. . For example if the activecell address is
D3
the range will be selected like A2:F2.
Thanks for your help.




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

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