Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove some rows in excel from vb.net 1

Status
Not open for further replies.

myrgir

Programmer
Feb 7, 2006
62
CA
Hi I update an excel worksheet from vb.net.
Sometime, I would like to take off some rows in this worksheet for example, row 20 to row 32.
How can I make it?

Code:
Dim exPoolSchedule As New Excel.Application
Dim wbPoolSchedule As Excel.Workbook
Dim wsPoolSchedule As Excel.Worksheet

wbPoolSchedule = exPoolSchedule.Workbooks(1)
wsPoolSchedule = wbPoolSchedule.Worksheets(1)
wsPoolSchedule.Cells(2, 4) = String.Format("{0:MMMM dd yyyy}", Today)
wsPoolSchedule.Cells(4, 2) = JobDr.Item("ProjectName")
wsPoolSchedule.Cells(5, 2) = JobDr.Item("ProjectLocation")
wsPoolSchedule.Cells(6, 2) = JobDr.Item("Room_volume")
...
exPoolSchedule.Visible = False
wsPoolSchedule.SaveAs(Path & "\" & "PoolSchedule Master May 20061.xls")
exPoolSchedule.Workbooks.Close()
 
Should be something like this ...

Code:
wsPoolSchedule.Range("20:32").Delete

HTH

Regards,
Zack Barresse

Simplicity is the ultimate sophistication. What is a MS MVP? PODA
- Leonardo da Vinci
 

Hi,

What does your code have to do with your question?

By "take of" do you mean ...

DELETE the ROWS?
Code:
wsPoolSchedule.Range(wsPoolSchedule.cells(20, 1), wsPoolSchedule.Cells(32,1)).EntireRow.Delete Shift:=xlup
DELETE the DATA in the rows?
Code:
wsPoolSchedule.Range(wsPoolSchedule.cells(20, 1), wsPoolSchedule.Cells(32,1)).EntireRow.ClearContents
COPY the ROWS?
Code:
wsPoolSchedule.Range(wsPoolSchedule.cells(20, 1), wsPoolSchedule.Cells(32,1)).EntireRow.Copy
CUT the ROWS?


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Skip, Sorry for the confusion, I meant delete de rows.

Fire, I tried this but it gives me the error that says
"Exeption from HRESULT: 0x800A02EC
Check the ErrorCode property of the exception to determine the HRESULT returned by the COM object.
Get general help for this exception.
 
Skip
xlup make me an error that is not declared...
 
Hmm, what about ..

Code:
wsPoolSchedule.Range("A20:A32").EntireRow.Delete

Does that work? Can you do anything with that range?

Regards,
Zack Barresse

Simplicity is the ultimate sophistication. What is a MS MVP? PODA
- Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top