FORMAT function not recognised - Compile error.

Herakles

Well-known Member
Joined
Jul 5, 2020
Messages
927
Office Version
  1. 365
Platform
  1. Windows
Hi All

The VBA FORMAT function is not being recognised.

A get a compile error.

VBA Code:
    For Each c In Selection
        c.Value = format(c.Value, "dd.mm.yyyy")
    Next c

Is there a specific library that I need referenced to access this function?

Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
What is the error message? If it's 'Can't find project or library' then it means you have a reference selected in your vb project that is not available on that machine.
 
Upvote 0
What is the error message? If it's 'Can't find project or library' then it means you have a reference selected in your vb project that is not available on that machine.

I get a compile error when I try to run the code. See image attached.

I can tell that there is a likely to be a problem because the word 'format' should turn to upper case when I carriage return.
 

Attachments

  • CompileError.JPG
    CompileError.JPG
    49.6 KB · Views: 1
Upvote 0
That would suggest that you have created your own routine called format somewhere. You can work around that by using VBA.Format in your code, but it's better to avoid using VBA keywords for your own routine/variable names.
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,653
Members
449,111
Latest member
ghennedy

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