Hi all I've tried in vain how to work out how I fix an issue I have when loading a userform that pulls the cell data from a specific row on a worksheet so a user can amend or add anything they need to. For ease of explanation I'll call this userform 'EditData'
The original row cell data is written to the worksheet from another userform with various textboxes all of which work perfectly and when a user saves this userform the data is written to the worksheet ok with no problems.
I am only having problems with the two specific cells when loading the 'EditData' Userform (both of which are dates) and having them formatted as a date when the form opens (shown in the code above.) If the relevant cell hasn't had a date written to the sheet it originally there is nothing to format so it errors out.
I've tried all sorts of ways to resolve this with 'If' statements etc in the LoadData sub and also by having two different LoadData Sub's 'LoadData 1' & 'LoadData 2' when the userform is activated preceded with another 'if' statement seeing if there is anything in the cells or not.
I've tried so many different ways to fix this I've literally lost the plot hence this thread. So if my question makes any sense I'd love to know what I need to do to get this to work.
Many thanks Paul
The original row cell data is written to the worksheet from another userform with various textboxes all of which work perfectly and when a user saves this userform the data is written to the worksheet ok with no problems.
VBA Code:
Public Sub LoadData()
With Sheet1.Range("A3").Offset(m_currentRow)
txbDepositDatePaid = .Cells(1, 10).Value
txbDepositDatePaid = Format(CDate(txbDepositDatePaid), "DD/MM/YYYY")
txbBalanceDatePaid = .Cells(1, 12).Value
txbBalanceDatePaid = Format(CDate(txbBalanceDatePaid), "DD/MM/YYYY")
End With
End Sub
I am only having problems with the two specific cells when loading the 'EditData' Userform (both of which are dates) and having them formatted as a date when the form opens (shown in the code above.) If the relevant cell hasn't had a date written to the sheet it originally there is nothing to format so it errors out.
I've tried all sorts of ways to resolve this with 'If' statements etc in the LoadData sub and also by having two different LoadData Sub's 'LoadData 1' & 'LoadData 2' when the userform is activated preceded with another 'if' statement seeing if there is anything in the cells or not.
I've tried so many different ways to fix this I've literally lost the plot hence this thread. So if my question makes any sense I'd love to know what I need to do to get this to work.
Many thanks Paul