#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default 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.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default 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.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default 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.

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default 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.

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default 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.

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default 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.


Reply
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
where can I see my question and answer? Yesterday I ask a question IP Excel Discussion (Misc queries) 2 May 10th 08 04:08 PM
VBA Question Farhad Excel Discussion (Misc queries) 3 September 12th 07 04:42 PM
if question Jules Excel Worksheet Functions 3 August 10th 06 08:34 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM


All times are GMT +1. The time now is 04:09 PM.

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"