Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
getting Run-time error '1004' Select Method of Worksheet Classfailed
Hello,
I've created excel sheet contains macros and connected with SQL query. I am getting error mentioned in subject line. Note: After recording the macro i've hide worksheet through VBA code with password. Before hiding worksheet macros was run fine but after hiding the worksheet it shows me above error. I am getting error on line " sheets("Sheet2"). Select. Sheet2 which is hidden by VBA code after macros was recorded. Below is whole query: Sub Finaloutput() ' ' Finaloutput Macro ' ' Keyboard Shortcut: Ctrl+a ' Sheets("Sheet2").Select Cells.Select Selection.Copy Sheets("Sheet6").Select Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array (1, 2, 3, 4, _ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), Replace:=True, PageBreaks:=False, _ SummaryBelowData:=True Selection.Copy Sheets("Sheet8").Select Range("J13").Select ActiveWindow.SmallScroll Down:=-15 Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Columns("A:A").Select Selection.SpecialCells(xlCellTypeBlanks).Select Application.CutCopyMode = False Selection.EntireRow.Delete Range("C8").Select Cells.Replace What:=" Total", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Cells.Select Selection.Copy Sheets("Sheet7").Select ActiveWindow.SmallScroll Down:=-24 Range("A1").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("K11").Select Sheets("Sheet5").Select Range("A7").Select Sheets("Sheet4").Select Range("AE5").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Application.CutCopyMode = False Selection.Copy Sheets("Sheet5").Select Range("A7").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Range("A7").Select Application.CutCopyMode = False ActiveWorkbook.Worksheets("Sheet5").Sort.SortField s.Clear ActiveWorkbook.Worksheets("Sheet5").Sort.SortField s.Add Key:=Range ("A7"), _ SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Sheet5").Sort .SetRange Range("A7:N162") .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With Range("G10").Select Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _ Formula1:="=0" Selection.FormatConditions (Selection.FormatConditions.Count).SetFirstPriorit y With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 65535 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False Range("J15").Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run-Time error '1004' : Select method of Range class failed | Excel Discussion (Misc queries) | |||
Run-time error '1004': Select method of Sheets class failed | Excel Programming | |||
Run-time error '1004': Select method of Range class failed | Excel Programming | |||
Select method of range class failed, Run time error 1004 | Excel Programming |