View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Minitman Minitman is offline
external usenet poster
 
Posts: 293
Default Identify Last Row

Greetings,

I have two sheets. One to check, verify or make new record with the
entries. The second is to store the data.

To verify is simply to look at each record until a mistake or omission
is discovered, then I must decide if a correction of this record is
required or a new record with slightly different data needs to be
made.

For a correction, I use the link from a Forms ComboBox, which gives me
the row number to modify.

For a new record to be made, from this record I just modified,
requires that I first make a copy of the last row in the data list,
copy it to the row just below the last row and then copy the data,
from the form that I modified, into this new last row, one cell at a
time.

I tried this sub to choose and copy to the correct row. Only the
modified chosen row works (because of the value in the ComboBox linked
cell):

Private Sub bCompleteRecordEdit_Click()
Dim lRowToEdit As Long
Dim lLastRow As Long

Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("CustList")
If MsgBox("Do want to modify this record or create a new record?
Click Yes to modify or No to create a new record.", vbYesNo, "What do
you want to do with this record?") = vbYes Then
lRowToEdit = Range("pfDisc").Value '<<<This choice works
Else
ws1.Activate 'This is the destination sheet

'<This is where debug kicked me out with
'Copy method of range class failed
ws1.Range("A65536").End(xlUp).Copy _
Destination:=Range("A65536").End(xlUp) + 1 '<<<

Application.CutCopyMode = False
lRowToEdit = Range("A65536").End(xlUp) + 1
End If

'PasteDown1 takes an argument which is
'the row that PasteDown1 is to work with.
PasteDown1 lRowToEdit
End Sub

Here is the PasteDown1 Sub:

Sub PasteDown1(lRowToModify As Long)
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("CustList")
Set ws2 = wb1.Worksheets("Print_Form")
With ws1.Range("A" & lRowToModify + 1)
For i = 4 To 79
.Offset(0, i).Value = _
ws2.Range("pfCell_" & i).Value
Next i
End With
End Sub

I think I need a different way to identify the last row.

Any ideas or pointers will be greatly appreciated.

-Minitman