#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Offset

Hello,

I am trying to write some code that will select row32 of the active cell.
This always needs to be row 32 becuase I want to get the interior colour
value of that cell and apply that to the active cell. Here is my code so far:

ActiveCell.Offset(Right(ActiveCell.Address, 2) - Right(ActiveCell.Address,
2) + 32, 0).Select

If I put this into a message box then it always returns 32 so I know that
works but it doesnt seem to work with the offset rule. Does anyone know why
this is?

I also need to get the value of the interior colour. i havent looked this
up yet but again if anyone can help with that it would be appreciated.

Martin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Offset

Hi,

This will get the colorindex from row 32 of the activecolumn and set the
activecell to that colour

Dim cIndex As Long
cIndex = Cells(32, ActiveCell.Column).Interior.ColorIndex
ActiveCell.Interior.ColorIndex = cIndex

or to do it all in one line

ActiveCell.Interior.ColorIndex = Cells(32,
ActiveCell.Column).Interior.ColorIndex


Mike

Mike

"Martin" wrote:

Hello,

I am trying to write some code that will select row32 of the active cell.
This always needs to be row 32 becuase I want to get the interior colour
value of that cell and apply that to the active cell. Here is my code so far:

ActiveCell.Offset(Right(ActiveCell.Address, 2) - Right(ActiveCell.Address,
2) + 32, 0).Select

If I put this into a message box then it always returns 32 so I know that
works but it doesnt seem to work with the offset rule. Does anyone know why
this is?

I also need to get the value of the interior colour. i havent looked this
up yet but again if anyone can help with that it would be appreciated.

Martin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Offset

On Tue, 30 Dec 2008 03:14:21 -0800, Martin
wrote:

Hello,

I am trying to write some code that will select row32 of the active cell.
This always needs to be row 32 becuase I want to get the interior colour
value of that cell and apply that to the active cell. Here is my code so far:

ActiveCell.Offset(Right(ActiveCell.Address, 2) - Right(ActiveCell.Address,
2) + 32, 0).Select

If I put this into a message box then it always returns 32 so I know that
works but it doesnt seem to work with the offset rule. Does anyone know why
this is?

I also need to get the value of the interior colour. i havent looked this
up yet but again if anyone can help with that it would be appreciated.

Martin


Your questions are not clear.

What do you mean by:

"row32 of the active cell." ??

An active cell is a single cell. It does not have 32 rows.

Do you mean the row 31 cells below the row of the active cell?
Do you mean the row 32 cells below the row of the active cell?

Also, you then write "I want to get the interior colour
value of that cell and apply that to the active cell." But selecting a 'cell'
is NOT the same as selecting a 'row'

And, if all you want is to set the activecell to the same color as some other
sell, there is no need to select anything.

For example, if you want to use the interior color of the cell that is 32 cells
below the active cell, you could use something as simple as:

ActiveCell.Interior.Color = ActiveCell(32).Interior.Color

Just remember that the row index of the active cell is "1-based". So that if
activecell is A1, activecell(32) would be A32. And if activecell is A8,
activecell(32) would be A39.

--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default Offset

Mike, thank you. Spot on.

Martin


"Mike H" wrote:

Hi,

This will get the colorindex from row 32 of the activecolumn and set the
activecell to that colour

Dim cIndex As Long
cIndex = Cells(32, ActiveCell.Column).Interior.ColorIndex
ActiveCell.Interior.ColorIndex = cIndex

or to do it all in one line

ActiveCell.Interior.ColorIndex = Cells(32,
ActiveCell.Column).Interior.ColorIndex


Mike

Mike

"Martin" wrote:

Hello,

I am trying to write some code that will select row32 of the active cell.
This always needs to be row 32 becuase I want to get the interior colour
value of that cell and apply that to the active cell. Here is my code so far:

ActiveCell.Offset(Right(ActiveCell.Address, 2) - Right(ActiveCell.Address,
2) + 32, 0).Select

If I put this into a message box then it always returns 32 so I know that
works but it doesnt seem to work with the offset rule. Does anyone know why
this is?

I also need to get the value of the interior colour. i havent looked this
up yet but again if anyone can help with that it would be appreciated.

Martin

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Offset

Glad I could help

"Martin" wrote:

Mike, thank you. Spot on.

Martin


"Mike H" wrote:

Hi,

This will get the colorindex from row 32 of the activecolumn and set the
activecell to that colour

Dim cIndex As Long
cIndex = Cells(32, ActiveCell.Column).Interior.ColorIndex
ActiveCell.Interior.ColorIndex = cIndex

or to do it all in one line

ActiveCell.Interior.ColorIndex = Cells(32,
ActiveCell.Column).Interior.ColorIndex


Mike

Mike

"Martin" wrote:

Hello,

I am trying to write some code that will select row32 of the active cell.
This always needs to be row 32 becuase I want to get the interior colour
value of that cell and apply that to the active cell. Here is my code so far:

ActiveCell.Offset(Right(ActiveCell.Address, 2) - Right(ActiveCell.Address,
2) + 32, 0).Select

If I put this into a message box then it always returns 32 so I know that
works but it doesnt seem to work with the offset rule. Does anyone know why
this is?

I also need to get the value of the interior colour. i havent looked this
up yet but again if anyone can help with that it would be appreciated.

Martin

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
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Programming 4 September 28th 07 09:59 PM
Find, Copy offset to offset on other sheet, Run-time 1004. Finny[_3_] Excel Programming 10 December 7th 06 11:46 PM
select offset (variable ,1) to offset(variable ,variable) Buffyslay Excel Programming 1 November 15th 06 11:45 AM
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) [email protected] Excel Programming 2 August 22nd 05 05:25 AM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"