Format cells based on format in combobox

camandab

Board Regular
Joined
Feb 10, 2010
Messages
79
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.


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
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,221,525
Messages
6,160,329
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top