Workbook_Open Not Working In ThisWorkbook

cicconmr

Board Regular
Joined
Jul 5, 2011
Messages
90
Let me know if I'm doing this correctly.

I'm double clicking the ThisWorkbook under Excel Object and adding in:

Private Sub Workbook_Open()

Call Sort

End Sub

That's it....can it have something to do with the way I saved my program? This should be working....right?
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Assuming you have macros enabled, yes it should run when you open the workbook. Sort is not really a good name for a macro though as it's also the name of a built-in Excel method.
 
Upvote 0
There is no error....the macro is simple enough, all it does is sort some columns in a hiding sheet when the data is updated via Bloomberg. BUt it still will not work unless I run it manually through the VBE.
 
Upvote 0
Private Sub Workbook_Open()
Call Organize_Macro

End Sub

Sub Organize_Macro()
'
' Sort sheet upon open
'
Application.ScreenUpdating = False

Worksheets("Hardware").Sort.SortFields.Clear
Worksheets("Hardware").Sort.SortFields.Add Key:=Range( _
"B2:B501"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With Worksheets("Hardware").Sort
.SetRange Range("A1:B501")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Worksheets("Hardware").Sort.SortFields.Clear
Worksheets("Hardware").Sort.SortFields.Add Key:=Range( _
"K2:K501"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With Worksheets("Hardware").Sort
.SetRange Range("J1:K501")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Worksheets("Hardware").Sort.SortFields.Clear
Worksheets("Hardware").Sort.SortFields.Add Key:=Range( _
"S2:S501"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With Worksheets("Hardware").Sort
.SetRange Range("R1:S501")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Worksheets("Hardware").Sort.SortFields.Clear
Worksheets("Hardware").Sort.SortFields.Add Key:=Range( _
"Z2:Z501"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With Worksheets("Hardware").Sort
.SetRange Range("Y1:Z501")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Worksheets("Hardware").Sort.SortFields.Clear
Worksheets("Hardware").Sort.SortFields.Add Key:=Range( _
"AH2:AH501"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Hardware").Sort
.SetRange Range("AG1:AH501")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Worksheets("Hardware").Sort.SortFields.Clear
Worksheets("Hardware").Sort.SortFields.Add Key:=Range( _
"AP2:AP501"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With Worksheets("Hardware").Sort
.SetRange Range("AO1:AP501")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Worksheets("Hardware").Sort.SortFields.Clear
Worksheets("Hardware").Sort.SortFields.Add Key:=Range( _
"AX2:AX501"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With Worksheets("Hardware").Sort
.SetRange Range("AW1:AX501")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Sheets("Panel").Select
Range("A12").Select

Application.ScreenUpdating = True
End Sub
 
Upvote 0
The Macro is working, the problem is it is moving faster than my Bloomberg links can update the data!

Is there a way one can put a time delay on calling the Organize_Macro?

I apologize for that.
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top