Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine two Codes into one Sheet | Excel Programming | |||
I create sheet using vb codes after that i want change sheet name | Excel Programming | |||
Code to delete shapes each time a sheet is deactivated | Excel Programming | |||
How can I make macros execute on a protected sheet? | Excel Programming | |||
Hidden page bracks in Excel should be deactivated | Excel Discussion (Misc queries) |