Hello,
I'm looking to format (or convert) cell values based on the format indicated in the combobox.
Below is my code. Each of the comboboxes contains a part of common date formats (e.g. 'mm', 'yyyy', 'dd', '/', '.', etc). I've stepped through and it's reading Date1 and Date2 in the proper formats but it doesn't find the match in the If statement. I may be trying to oversimplify my code or am missing something fundamental. Any guidance would be much appreciated.
I'm looking to format (or convert) cell values based on the format indicated in the combobox.
Below is my code. Each of the comboboxes contains a part of common date formats (e.g. 'mm', 'yyyy', 'dd', '/', '.', etc). I've stepped through and it's reading Date1 and Date2 in the proper formats but it doesn't find the match in the If statement. I may be trying to oversimplify my code or am missing something fundamental. Any guidance would be much appreciated.
Code:
Private Sub cmdOK_Click()
Dim cell As Range
Dim Date1 As String
Dim Date2 As String
Date1 = cboCurr1.Value & cboCurr2.Value & cboCurr3.Value & cboCurr4.Value & cboCurr5.Value
Date2 = cboConv1.Value & cboConv2.Value & cboConv3.Value & cboConv4.Value & cboConv5.Value
For Each cell In Selection.Cells
If cell.Value = Format(Date, Date1) Then
cell.Value = Format(Date, Date2)
End If
Next cell
End Sub