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: 75
Default Execute Codes after Sheet Deactivated

Hello all,

I have an Excel file with multiple sheets. I like to write a code to
execute a series of codes after I leave the sheet "abc". So I write the
following code in VB of Sheet "abc":

Private Sub Worksheet_Deactivate()

Range("a10:a64").Select
Selection.Copy
Range("o10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
skipblanks _
:=False, Transpose:=False

Range("N10").Select
ActiveCell.FormulaR1C1 = _
"=IF(LEN(RC[-13])=3,CONCATENATE(""a"",RC[-13]),RC[-13])"
Range("N10:N64").Select
Selection.FillDown

Range("n10:n64").Select
Selection.Copy
Range("a10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
skipblanks _
:=False, Transpose:=False

Rows("10:65").Select
Selection.Sort Key1:=Range("A11"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Range("o10:o64").Select
Selection.Copy
Range("a10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
skipblanks _
:=False, Transpose:=False

Range("n10:o64").Select
Selection.Clear
Range("a1").Select

end sub

When I leave/deactivate the abc sheet, I got the following error:

Run-time error '1004': Select method of Range class failed

When I debug it, it points to Range("a10:a64").Select.

Please help. How can I write a code to execute the codes after leaving the
sheet?

Thanks.
 
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
Combine two Codes into one Sheet Steved Excel Programming 2 May 19th 08 02:29 AM
I create sheet using vb codes after that i want change sheet name Parthiban Excel Programming 1 February 21st 08 05:51 AM
Code to delete shapes each time a sheet is deactivated DlgomesBR Excel Programming 2 November 4th 07 12:51 PM
How can I make macros execute on a protected sheet? J Scott Excel Programming 2 July 26th 05 04:02 PM
Hidden page bracks in Excel should be deactivated Tonywww Excel Discussion (Misc queries) 0 December 21st 04 06:21 PM


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