T
Terry
I am currently writing an MS Access DB program that modifies a Excel
spreadsheet. I am search a table on the sheet and where the search values
match I am deleting cells from a row. I am deleting the first 7 columns from
the row and shifting the cells up.
The code I have works to a point. Out of the several hundred rows only a
handful are being deleted. I am deleting them row by row since they will not
always appear in sequence.
thanks
**************************************
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim BegRange As Excel.Range
Dim EndRange As Excel.Range
Dim Row as Integer
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open("C:\temp\Video Churn
Report_v_2007_06_22", 0, False)
Set xlSheet = xlBook.Worksheets("Q1-Insvc_Disc Data")
' This code searchs the sheet for matching variables.
' If found it sets the range to delete and then deletes them shifting up
Do While xlSheet.Cells(Row, 1).Value <> ""
If xlSheet.Cells(Row, 1).Value = "terry" Then
'MsgBox Row
Set BegRange = xlSheet.Cells(Row, 1)
Set EndRange = xlSheet.Cells(Row, 7)
xlSheet.Cells.Range(BegRange, EndRange).Delete (xlUp)
End If
Row = Row + 1
Loop
spreadsheet. I am search a table on the sheet and where the search values
match I am deleting cells from a row. I am deleting the first 7 columns from
the row and shifting the cells up.
The code I have works to a point. Out of the several hundred rows only a
handful are being deleted. I am deleting them row by row since they will not
always appear in sequence.
thanks
**************************************
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim BegRange As Excel.Range
Dim EndRange As Excel.Range
Dim Row as Integer
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open("C:\temp\Video Churn
Report_v_2007_06_22", 0, False)
Set xlSheet = xlBook.Worksheets("Q1-Insvc_Disc Data")
' This code searchs the sheet for matching variables.
' If found it sets the range to delete and then deletes them shifting up
Do While xlSheet.Cells(Row, 1).Value <> ""
If xlSheet.Cells(Row, 1).Value = "terry" Then
'MsgBox Row
Set BegRange = xlSheet.Cells(Row, 1)
Set EndRange = xlSheet.Cells(Row, 7)
xlSheet.Cells.Range(BegRange, EndRange).Delete (xlUp)
End If
Row = Row + 1
Loop