I also tried to write: FinalRow = Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To finalrow If IsDate = True Then Cells.NumberFormat = "dd/mm/yyyy" End If Next i but i get an error: Argument not optional.
On Friday, May 30, 2014 12:07:47 PM UTC+3, Kof Bar wrote: > > I recorded a macro, and this is my code, but i don't know how to change > cells containing dates to dates format: > > Sub AccFormat() > ' > ' AccFormat macro > ' Format Cells as accounting, except date cells. > ' > ' shortcut: Ctrlþ+Shift+A > ' > Cells.Select > Selection.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* > ""-""??_);_(@_)" > End Sub > > I have shorted the code to: > > cells.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* ""-""??_);_(@_)" > > The workbook is hereby attached. > > Thanks, Kof. > > > > On Friday, May 30, 2014 11:02:34 AM UTC+3, Kof Bar wrote: >> >> Hi, >> >> I would like to create a macro that will format all cells in a worksheet >> to accounting format: >> >> _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_) >> >> except cells conatinig dates. >> >> >> >> Thanks, Kof. >> > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.
AccFormat.xlsm
Description: application/vnd.ms-excel.sheet.macroenabled.12