need an unusual macro

Tempus

Board Regular
Joined
May 11, 2006
Messages
56
i need a macro that will sort the rows by the Time column (soonest time first) and then saves the top 50 as in HTML. the colums will be the same on each row of course, but the are not linear (not a-Z) i need a-g, then Y, then AA and AB.\
can anyone help? i'm totally stumped.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Tempus,

Hopefully the following code will do what you want. Please note it assumes that the 'Time' column is in column A, if this is not the case the sorting part of the code will need adjusting slightly

Code:
Option Explicit

Sub Sort()

Application.ScreenUpdating = False

'Set current sheet for resetting later
Dim OriginalSheet As String
OriginalSheet = ActiveSheet.Name

'Sort all cells (assumes time is in column A)
Range("A1", Cells(ActiveSheet.Rows.Count, ActiveSheet.Columns.Count)).Sort _
    Key1:=Range("A3"), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, _
    MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
        
'copy requried columns into new sheet
Range("A1:G50,Y1:Y50,AA1:AB50").Copy
Sheets.Add Before:=Sheets(1)
ActiveSheet.Paste
Application.CutCopyMode = False

'publish html in c drive
ActiveWorkbook.PublishObjects.Add(xlSourceSheet, _
"C:\Test.html", ActiveSheet.Name, "", xlHtmlStatic).Publish (True)

'delete the created sheet
Application.DisplayAlerts = False
Sheets(ActiveSheet.Name).Delete
Application.DisplayAlerts = True

'reset selected sheet
Sheets(OriginalSheet).Select
Application.ScreenUpdating = True

End Sub

Any questions please let me know.

Cheers,
alx7000
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,841
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