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: 19
Default Macro working in background ie not on activesheet

I have a few macros that I am working on that move between different sheets.
I am trying to have them operate in the background rather than on the
ActiveSheet, but I can't figure out the syntax.

' Macro3 Macro
' Macro recorded 5/23/2005 by A0jxvzz
'declarations
Dim MyFromColumn As Integer
Dim MyToColumn As Integer
Dim MyFromStartCell As String
Dim MyFromEndCell As String
Dim MyToStartCell As String
Dim MyToEndCell As String
Dim MyNamedRange As Range
Dim MyRangeName(1 To 11) As String
Dim Counter


For Counter = 1 To 11

MyRangeName(Counter) = "ComplntCd" & Counter
Next



'Clear Area
Sheets("Data").Select
Range("AA1:AZ1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents

'AutoFilter
For MyFromColumn = 1 To 11

MyToColumn = MyFromColumn + 26

MyFromStartCell = Cells(1, MyFromColumn).Address
MyFromEndCell = Cells(65536, MyFromColumn).Address
MyToStartCell = Cells(1, MyFromColumn + 26).Address
MyToEndCell = Cells(65536, MyFromColumn + 26).Address
Range(MyFromStartCell & ":" & MyFromEndCell).AdvancedFilter
Action:=xlFilterCopy, CopyToRange:=Range(MyToStartCell), Unique:=True
'Sort
Range(MyToStartCell & ":" & MyToEndCell).Select
Selection.Sort Key1:=Cells(2, MyToColumn), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Define Name
Set MyNamedRange = Range(MyToStartCell & ":" & MyToEndCell)
ActiveWorkbook.Names.Add Name:=MyRangeName(MyFromColumn),
RefersToR1C1:=MyNamedRange

Next

'Move Away from ActiveSheet
Sheets("Front").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
Macro in Background Hager Excel Discussion (Misc queries) 2 January 19th 10 10:17 AM
activesheet.tab.colorindex not working when workbook shared Martin Appleton Excel Discussion (Misc queries) 0 July 21st 06 08:45 AM
Working with Macros-Activesheet.Paste lunar1085 Excel Discussion (Misc queries) 0 February 3rd 06 04:13 PM
ActiveSheet in a Macro? Randy S[_4_] Excel Programming 3 February 1st 05 02:19 PM
ActiveSheet.Next.Select not working! Ron McCormick[_2_] Excel Programming 2 December 15th 03 12:42 PM


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