chipsworld
Board Regular
- Joined
- May 23, 2019
- Messages
- 169
- Office Version
- 365
Not sure where this is wrong , but...
The below only puts new data on Row 35. If Row 35 has data, it will simply write over it. Where am I wrong? This is making me crazy!
Currently there is data on Rows 2 and 3 and then nothing until 35. Row 1 is the header Row...
The below only puts new data on Row 35. If Row 35 has data, it will simply write over it. Where am I wrong? This is making me crazy!
Currently there is data on Rows 2 and 3 and then nothing until 35. Row 1 is the header Row...
VBA Code:
Public Sub PDMRA_Copy()
Dim rw As Long
Dim DestWS As Worksheet
Dim smname As String
smname = frmPDMRAcalc.txtnam2.Value
Set DestWS = Sheets("PDMRA History")
On Error Resume Next
With DestWS
rw = .Range("A:A").Find(smname, LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlPrevious).Row
If rw <> 0 Then
.Range("B" & rw).Value = frmPDMRAcalc.txtqmobsrt.Value
.Range("C" & rw).Value = frmPDMRAcalc.txtqmobend.Value
.Range("D" & rw).Value = frmPDMRAcalc.cmbqcomp.Value
.Range("E" & rw).Value = frmPDMRAcalc.cmbqusc.Value
.Range("F" & rw).Value = frmPDMRAcalc.cmbqcntry.Value
.Range("G" & rw).Value = frmPDMRAcalc.txtcmobsrt.Value
.Range("H" & rw).Value = frmPDMRAcalc.txtcmobend.Value
.Range("I" & rw).Value = frmPDMRAcalc.cmbccomp.Value
.Range("J" & rw).Value = frmPDMRAcalc.cmbcusc.Value
.Range("K" & rw).Value = frmPDMRAcalc.cmbccntry.Value
.Range("L" & rw).Value = frmPDMRAcalc.txtmonthsdwell.Value
.Range("M" & rw).Value = frmPDMRAcalc.txtpdmraern.Value
.Range("N" & rw).Value = frmPDMRAcalc.txtmnthsearned.Value
.Range("O" & rw).Value = Sheets("Formulas").Range("AC16").Value
.Range("P" & rw).Value = Sheets("Formulas").Range("AC17").Value
Else
rw = Range("A" & Rows.Count).End(xlUp).Row + 1
.Range("A" & rw).Value = frmPDMRAcalc.txtnam2.Value
.Range("B" & rw).Value = frmPDMRAcalc.txtqmobsrt.Value
.Range("C" & rw).Value = frmPDMRAcalc.txtqmobend.Value
.Range("D" & rw).Value = frmPDMRAcalc.cmbqcomp.Value
.Range("E" & rw).Value = frmPDMRAcalc.cmbqusc.Value
.Range("F" & rw).Value = frmPDMRAcalc.cmbqcntry.Value
.Range("G" & rw).Value = frmPDMRAcalc.txtcmobsrt.Value
.Range("H" & rw).Value = frmPDMRAcalc.txtcmobend.Value
.Range("I" & rw).Value = frmPDMRAcalc.cmbccomp.Value
.Range("J" & rw).Value = frmPDMRAcalc.cmbcusc.Value
.Range("K" & rw).Value = frmPDMRAcalc.cmbccntry.Value
.Range("L" & rw).Value = frmPDMRAcalc.txtmonthsdwell.Value
.Range("M" & rw).Value = frmPDMRAcalc.txtpdmraern.Value
.Range("N" & rw).Value = frmPDMRAcalc.txtmnthsearned.Value
.Range("O" & rw).Value = Sheets("Formulas").Range("AC16").Value
.Range("P" & rw).Value = Sheets("Formulas").Range("AC17").Value
End If
End With
End Sub