Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I want to open an Excel workbook, sort the data, remove subtotals and save it. Then I want to import the data into a dataset - I can do that using ADO or perhaps reading each row and inserting it into a datatable. I have used Excel VBA to outline what I want to achieve but I am having difficulty translating the syntax. Any assistance translating this code would be greatly appreciated. Thanks in advance REgards Habib ----------- VBA Code: ----- Sub Cleanfile() Dim l As Long Worksheets(1).Select Range("A1:O1").Value = Array("Name", "Address1", "Address2", "Address3", "City", "State", "Zip", "StartDate" "Num") l = Range("A65536").End(xlUp).Row Range("A" & l).Select Rows(2).Resize(l - 1).Sort Key1:=Range("H2"), order1:=xlDescending, Header:=xlNo l = Range("A65536").End(xlUp).Row Range("A" & l).Select For i = 2 To l If Not IsDate(Cells(i, 8).Value) Then Cells(i, 8).Value = Date If Not IsNumeric(Cells(i, 9).Value) Then Rows(i).ClearContents Else If Cells(i, 9).Value = 0 Then Rows(i).ClearContents If Left(Cells(i, 1).Value, 8) = "SubTotal" Then Rows(i).ClearContents ElseIf Left(Cells(i, 1).Value, 11) = "Grand_Total" Then Rows(i).ClearContents End If End If Next l = Range("A65536").End(xlUp).Row Range("A" & l).Select Rows(2).Resize(l - 1).Sort Key1:=Range("H2"), order1:=xlDescending, Header:=xlNo Rows(l).Select ActiveWorkbook.SaveAs "Demo.xls" End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I manipulate data pulled from within an excel calendar? | Excel Discussion (Misc queries) | |||
Manipulate an excel column | Excel Worksheet Functions | |||
Can you manipulate text documents using VBA in excel | Excel Programming | |||
Manipulate Excel | Excel Programming | |||
excel 2000 - manipulate two applications | Excel Programming |