>Hi Thomas,
>
>Thanks again. You have been a big help.
>
>Sub 1()
>Range("C3").Select
>Selection.End(xlDown).Select
>Selection.EntireRow.Delete
>End Sub
>
>This works in that it allows me to select the rows between C3 and the next filled cell, without me having to know where the next cell is. This is important since the detail and the totals are inserted via VBA in a VFP program. The problem is that unlike Lotus it includes the next filled cell.
>Hence the Totals row will be deleted.
>
>When I recorded a macro to Shift/End/Down, Shift/Up the result didn't copy my keystrokes. It just redefined the range.
>
>Is there a way to Select/redefine the range -1?
>
>Regards,
>
>Paige
I recorded the macro and the selection was the cells in the rows to be deleted. If you are sending the data to Excel from VFP, you may be better off using an alternative to the Range collection.
Excel has two ways to reference a cell. The Macro recorder uses the Range collection. The alternative is the Cell collection. The biggest advantage of the Range is that you can address a range.
Range("C3").Select would be Cells(3,3). The syntax is Cells(<rows>,<cols>). I find this notation easier to work with in Fox.
Example:
*- I want to start at the third row
lnRow = 3
SCAN
*- Read the record into the worksheet at column D.
.Cells(lnRow, 4).Value = myfile.thisfield
lnRow = lnRow + 1
ENDSCAN
lcRange = "D3:D:"+ALLTRIM(STR(lnRow-1))
You can use lcRange to select the rows to be deleted.
I am assuming that you are sending the total from Fox, so I deducted 1 from the row number. A good explanation of this is available at
www.informit.com. You can view Menachem Bazian's book. This subject is in Chapter 21.
If you are sending a lot of data to Excel, you can improve performance by turning the calculation to manual. The default calculation in Excel causes every cell to be calculated when an entry is made.
When you open your excel object, try this line.
Application.Calculation = xlManual
If you use a formulas in Excel you would need this line to update.
Calculate
Good Luck
Tom Molloy