Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 07-10-2012, 10:41 AM
gbaker gbaker is offline Run Code when Workbook opens Windows 7 32bit Run Code when Workbook opens Office 2010 32bit
Competent Performer
Run Code when Workbook opens
 
Join Date: May 2012
Posts: 111
gbaker is on a distinguished road
Default Run Code when Workbook opens

Hi Colin,
Again you made it easy. Thanks for your help.
Question:
I never was able to get the code you provided to sort my sheet the way I need it too.
Here is the code and I attached a workbook to show what I'm looking for. I really don't understand this one. Maybe you can explain and tell me what I need to do.
Code:
Sub SortDaysProvider()
    Dim DayRange As Long
    Dim TopRow As Long
    Dim sRange As Range
    Dim fRange As Range
 
    Application.ScreenUpdating = False
 
    For DayRange = 1 To 365
        TopRow = (DayRange * 17) + 9
 
        With ActiveWorkbook.Worksheets("Input Calendar (2012)")
 
            Set sRange = .Range("B" & TopRow & ":" & "O" & TopRow + 5)
            Set fRange = .Range("B" & TopRow & ":" & "B" & TopRow + 5)
 
            With .Sort
                .SortFields.Add _
                     Key:=fRange, _
                     SortOn:=xlSortOnValues, _
                     Order:=xlAscending, _
                     DataOption:=xlSortNormal
                 .SetRange sRange
                 .Header = xlGuess
                 .MatchCase = False
                 .Orientation = xlTopToBottom
                 .SortMethod = xlPinYin
                 Application.Calculate
                 .Apply
                 .SortFields.Clear
            End With
        End With
    Next DayRange
 
    Application.ScreenUpdating = True

End Sub
Attached Files
File Type: xlsm Test sorting sheet.xlsm (227.6 KB, 11 views)
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word opens with 2 pgs jmacky Word 4 01-28-2013 09:10 AM
Run Code when Workbook opens #REF! error when opening a workbook that contain a refference to another workbook tanababa Excel 2 06-07-2012 03:11 PM
Range(Cell1,Cell2) Error on another workbook controlling some other workbook? tinfanide Excel Programming 1 02-09-2012 04:08 PM
Run Code when Workbook opens macro to transfer data from one workbook to another workbook virsojour Excel Programming 5 02-01-2011 08:58 PM
Run Code when Workbook opens Select a range in one one workbook while working in other workbook Slow&Steady Excel 1 02-21-2010 03:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft