Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting simple range relative to the active cell.

I need to have my macro select the 9 cells starting with the active cell in
column B and extending 8 cells to the right. I am doing this as a custom
"copy range" funtion in a macro. I do not want an absolute reference for the
range. It should be relative to any ACTIVE cell in column B.

If there is no ACTIVE cell in column B, then I would like to return an error
message "Wrong Column Selected" with and "O.K." button.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Selecting simple range relative to the active cell.

Give this a try...

Sub SelectRange()

If ActiveCell.Column = 2 Then
ActiveCell.Resize(1, 9).Select
Else
MsgBox "Sorry. You are in the wrong column...", _
vbInformation, "Wrong Column"
End If
End Sub

--
HTH...

Jim Thomlinson


"jmac68" wrote:

I need to have my macro select the 9 cells starting with the active cell in
column B and extending 8 cells to the right. I am doing this as a custom
"copy range" funtion in a macro. I do not want an absolute reference for the
range. It should be relative to any ACTIVE cell in column B.

If there is no ACTIVE cell in column B, then I would like to return an error
message "Wrong Column Selected" with and "O.K." button.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Selecting simple range relative to the active cell.

Dim newRng As Range
If Not ActiveCell.Column = 2 Then
MsgBox "You selected a cell in the wrong column"
Else
rowStr = CStr(ActiveCell.Row)
Set newRng = Range("$B$" & rowStr & ":$J$" & rowStr)
newRng.Select
End If

Steve


"jmac68" wrote in message
...
I need to have my macro select the 9 cells starting with the active cell in
column B and extending 8 cells to the right. I am doing this as a custom
"copy range" funtion in a macro. I do not want an absolute reference for
the
range. It should be relative to any ACTIVE cell in column B.

If there is no ACTIVE cell in column B, then I would like to return an
error
message "Wrong Column Selected" with and "O.K." button.



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
Selecting Range in non-active sheet [email protected] Excel Programming 0 March 27th 06 01:44 PM
Range selecting in non-active workbook SJC[_2_] Excel Programming 3 December 30th 05 01:55 PM
Selecting an active cell TimT Excel Programming 3 October 27th 05 07:08 PM
Specifying cell reference relative to active cell DeepDarkThought Excel Programming 1 May 6th 04 08:17 PM
selecting a cell relative to activecell in an excel macro Zogann Excel Programming 1 October 17th 03 12:20 PM


All times are GMT +1. The time now is 10:15 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"