J
jfcby
Hello,
My workbook has 100 worksheets and I'm using the code below to makes to
all of them:
Sub EquipListFFPageSort()
'
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ActiveWorkbook.Worksheets
sh.Select
'Your format code
Range("A1:C65536").Select
Application.Run
"EQUIP_LIST_Macros.xls!DeleteBlankSpacesOnTheLeftAndRight"
Range("C4:C65536").Select
Selection.Copy
Range("D4").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("D65530").Select
ActiveCell.FormulaR1C1 = "ABC"
Range("D65531").Select
ActiveCell.FormulaR1C1 = "DEF"
Range("D65532").Select
ActiveCell.FormulaR1C1 = "GHI"
Range("D65533").Select
ActiveCell.FormulaR1C1 = "JKL"
Range("D4
65536").Select
Application.Run "EQUIP_LIST_Macros.xls!RemoveAlphas"
Range("A4
65536").Select
Selection.Sort Key1:=Range("B4"), Order1:=xlAscending,
Key2:=Range("D4") _
, Order2:=xlAscending, Key3:=Range("C4"), Order3:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:= _
xlSortNormal
Columns("D
").Select
Selection.ClearContents
Range("A1").Select
Application.ScreenUpdating = True
Next sh
End Sub
But when I run this code it goes through about 15 worksheets and gives
me these two error messages:
Microsoft Excel Error Message
Excel cannot complete task with available resources. Choose less data
or close other applications.
After I close this error message it brings up this error message:
Microsoft Visual Basic Error Message
Run-time error '1004':
Paste method of Worksheet class failed
Then I click debug and ActiveSheet.Paste is highlighted in my code.
How can I get this code to run without causing any errors?
Thank you for your help in advance,
jfcby
My workbook has 100 worksheets and I'm using the code below to makes to
all of them:
Sub EquipListFFPageSort()
'
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ActiveWorkbook.Worksheets
sh.Select
'Your format code
Range("A1:C65536").Select
Application.Run
"EQUIP_LIST_Macros.xls!DeleteBlankSpacesOnTheLeftAndRight"
Range("C4:C65536").Select
Selection.Copy
Range("D4").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("D65530").Select
ActiveCell.FormulaR1C1 = "ABC"
Range("D65531").Select
ActiveCell.FormulaR1C1 = "DEF"
Range("D65532").Select
ActiveCell.FormulaR1C1 = "GHI"
Range("D65533").Select
ActiveCell.FormulaR1C1 = "JKL"
Range("D4
65536").SelectApplication.Run "EQUIP_LIST_Macros.xls!RemoveAlphas"
Range("A4
65536").SelectSelection.Sort Key1:=Range("B4"), Order1:=xlAscending,
Key2:=Range("D4") _
, Order2:=xlAscending, Key3:=Range("C4"), Order3:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:= _
xlSortNormal
Columns("D
").SelectSelection.ClearContents
Range("A1").Select
Application.ScreenUpdating = True
Next sh
End Sub
But when I run this code it goes through about 15 worksheets and gives
me these two error messages:
Microsoft Excel Error Message
Excel cannot complete task with available resources. Choose less data
or close other applications.
After I close this error message it brings up this error message:
Microsoft Visual Basic Error Message
Run-time error '1004':
Paste method of Worksheet class failed
Then I click debug and ActiveSheet.Paste is highlighted in my code.
How can I get this code to run without causing any errors?
Thank you for your help in advance,
jfcby