LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Use same macro on 2 sheets?

I have a workbook with 2 sheets. Both sheets contain a sparce matrix of
data in which the Column Title row and the first column are the only
gauranteed row and column to be filled. I want to select the entire sparse
matrix.

The code below correctly selects the sparse matrix on one sheet, but when I
switch to the 2nd sheet it selects only the 1st row of the matrix.

Any help would be appreciated.

Option Explicit
Dim TopCell, LstRow, LstCol, LstCell, ActiveData As Range

Sub SelActiveData()
Dim NumCol As Integer
ActiveSheet.Select
'
' Selects active data whe
' TopCell is left most cell of column title row
'
NumCol = 14
Set TopCell = ActiveSheet.Range("A2")
Set LstRow = TopCell.End(xlDown)
Set LstCell = LstRow.Offset(0, NumCol)
Set ActiveData = _
ActiveSheet.Range(TopCell.Offset(1, 0), LstCell)
ActiveData.Select

End Sub


 
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
Run macro on all sheets trey1982 Excel Worksheet Functions 3 April 7th 09 03:07 AM
Using the same macro on different sheets Beverly Darvill[_2_] Excel Worksheet Functions 7 August 21st 08 06:26 PM
"With Sheets" Issue - macro on one sheet to affect hidden rows on other sheets Punsterr Excel Programming 3 February 21st 06 04:01 AM
Macro for filter on protected workbook that works for all sheets, no matter what sheets are named? StargateFanFromWork[_3_] Excel Programming 6 January 26th 06 06:31 PM
macro/new sheets daolb Excel Discussion (Misc queries) 5 June 29th 05 10:59 AM


All times are GMT +1. The time now is 08:39 AM.

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"