photon_ed
05-21-2006, 10:15 AM
Hello,
Can someone tell me as to why microsoft VB seems to have a problem running the line "Selection.Sort Key1:=Range("h1"), ..." in the program below. However, the line of code runs stand alone. Please advise. Thank you.
yours,
Ed
Sub Daily_Click()
'copyAndPasteColumns
'------------------------------------------------------
'------------------------------------------------------
Dim inData As Integer
Data = Array(1, 3, 5, 7, 9, 11, 13, 24, 32, 33, 34, 35, 36, 37, 38, 39, 40, 44, 47, 51, 52, 53, 54, 0)
inData = 0
Sheets(1).Select
ActiveSheet.Range("a1").Select
Sheets(2).Select
ActiveSheet.Range("a1").Select
Do Until Data(inData) = 0
ActiveSheet.Columns(Data(inData)).Copy
Sheets(1).Select
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Select
Sheets(2).Select
'MsgBox Data(inData)
inData = inData + 1
Loop
'------------------------------------------------------
'------------------------------------------------------
Sheets(1).Select
ActiveSheet.Range("h1").Select
Selection.Sort Key1:=Range("h1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Sheets(1).Select
ActiveSheet.Range("a1").Select
ActiveCell.EntireRow.Insert
Sheets(4).Select
ActiveSheet.Range("a1").Select
ActiveSheet.Rows(1).Copy
Sheets(1).Select
ActiveSheet.Range("a1").Select
ActiveCell.EntireRow.Insert
'ActiveSheet.Paste
ActiveSheet.Columns("P:Q").Select
Selection.Style = "percent"
Selection.NumberFormat = "0.00%"
ActiveWindow.DisplayGridlines = False
ActiveSheet.Columns.Select
ActiveSheet.Columns.AutoFit
ActiveCell.Range("a1").Select
ActiveWorkbook.Save
End Sub
Can someone tell me as to why microsoft VB seems to have a problem running the line "Selection.Sort Key1:=Range("h1"), ..." in the program below. However, the line of code runs stand alone. Please advise. Thank you.
yours,
Ed
Sub Daily_Click()
'copyAndPasteColumns
'------------------------------------------------------
'------------------------------------------------------
Dim inData As Integer
Data = Array(1, 3, 5, 7, 9, 11, 13, 24, 32, 33, 34, 35, 36, 37, 38, 39, 40, 44, 47, 51, 52, 53, 54, 0)
inData = 0
Sheets(1).Select
ActiveSheet.Range("a1").Select
Sheets(2).Select
ActiveSheet.Range("a1").Select
Do Until Data(inData) = 0
ActiveSheet.Columns(Data(inData)).Copy
Sheets(1).Select
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Select
Sheets(2).Select
'MsgBox Data(inData)
inData = inData + 1
Loop
'------------------------------------------------------
'------------------------------------------------------
Sheets(1).Select
ActiveSheet.Range("h1").Select
Selection.Sort Key1:=Range("h1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Sheets(1).Select
ActiveSheet.Range("a1").Select
ActiveCell.EntireRow.Insert
Sheets(4).Select
ActiveSheet.Range("a1").Select
ActiveSheet.Rows(1).Copy
Sheets(1).Select
ActiveSheet.Range("a1").Select
ActiveCell.EntireRow.Insert
'ActiveSheet.Paste
ActiveSheet.Columns("P:Q").Select
Selection.Style = "percent"
Selection.NumberFormat = "0.00%"
ActiveWindow.DisplayGridlines = False
ActiveSheet.Columns.Select
ActiveSheet.Columns.AutoFit
ActiveCell.Range("a1").Select
ActiveWorkbook.Save
End Sub