Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selecting Range in non-active sheet | Excel Programming | |||
Range selecting in non-active workbook | Excel Programming | |||
Selecting an active cell | Excel Programming | |||
Specifying cell reference relative to active cell | Excel Programming | |||
selecting a cell relative to activecell in an excel macro | Excel Programming |