LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using C# to manipulate Excel

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I manipulate data pulled from within an excel calendar? wkalmbach Excel Discussion (Misc queries) 1 August 21st 07 03:46 PM
Manipulate an excel column Bill R Excel Worksheet Functions 2 May 17th 05 07:01 PM
Can you manipulate text documents using VBA in excel Sladey Excel Programming 1 May 17th 04 05:11 PM
Manipulate Excel Bich Leu Excel Programming 3 August 25th 03 11:57 PM
excel 2000 - manipulate two applications Matt. Excel Programming 5 July 10th 03 03:38 PM


All times are GMT +1. The time now is 01:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"