Close Window
Free Ebook
Get Your Free Excel
Top 15 Excel Tutorials from
Instant Access!

Format - Vba Compile Error

The following code worked without problem when written in a standard form module

Me!txtBPRptStart = Format(Now() - 90, "short date")

but since I included it in my add-in I keep getting a compile error "wrong number of assignments or invalid property assignment"

I cant see what has changed to cause the problem
Can any one help with a suggestion as to where to start?

Free Excel Courses

Similar Excel Tutorials

How to add, manage, and remove error bars in charts in Excel. Error bars allow you to show the potential variance ...

How to prevent errors from appearing in formulas in Excel. This is especially helpful for the Vlookup function. Sec ...

How to remove the #N/A error from Vlookup and replace it with a friendly message or a blank cell. Fix the Vlookup ...

Ill show you how to use Excel to calculate the total time worked in a day minus lunch time or any breaks. This is ...

Helpful Excel Macros

- This free Excel macro applies the Short Date number format to a selection of cells in Excel. This number format display

- This free Excel macro formats a selection of cells in the Long Date number format in Excel. The Long Date number format

- This free Excel macro allows you to quickly and easily format a selection of cells in the Currency number format in Exce

- Delete all chart sheets and tabs in Excel using this macro. This will only delete the charts and graphs that are in the

- This free Excel macro formats selected cells in the Scientific number format in Excel. This means the cell will be put

Similar Topics

Good afternoon,

Is there a way to enter a colon into a standard number to create a value that can be formatted into a 24 hour time value ?

eg a time is listed as 1345 with a general number format, and I want it returned as 13:45 witha custom format of hh:mm.

Other than creating a table and using a vlookup function, I am hoping there is a better way?


Hi All,

I've been struggling with this for a while now and can't believe how hard it is!. I've searched on this site and on others to get some clarification but to no avail.

It's pretty simple really. I have a user form which contains a tex box for a user to input the date I want the format to be dd/mm/yyyy but can't find out how to set the format of the text box to this.

Please can someone give me a bit of guidence or link me to a good rescource if missed it in the search.

Thanks in advance.


I am trying to figure out how to write a formula to figure out production cycle time.
We will be building 8 "widgets" a day.
We will work 10 hours a day.
There is a 20 minute break at 9:20 am.
Production shuts down for lunch 30 minutes for lunch at 12:30.
Production starts at 6:00 am.
Here is what I can do.
Production cycle time = (10*60)-30/8 or 71.25 minutes
If we start at 6:00 am, the first scheduled cycle completion time = TIME(6,0,0+71.25/1440)

My problem is when I am trying to use a logical "IF' statement to account for the 20 minute break or lunch and still calculate the end of each cycle time through the day I receive a number of error messages.
This is the formula I am trying to make work. I have the cell the formula is in, formatted with a "mm,ss" format.
I have included an attachment to help (a picture is worth a thousand words).

Any help will be greatly appreciated.
I have bought a number of books in an attempt to figure this out, and I am still stumped

I have data with time in standard fromat i.e. 3:00PM but I need it to be in
24 hour format i.e. 15:00. How can I do this?

I am looking for assistance in having one cell in a text format equals another cell that contains a time value in hh:mm format.

For example: Cell A1 has a time format (hh:mm) value of 04:00; which is the Start Time. I would like cell D1 to have a text format value of "04:00" (result is dependant upon what is entered in A1). I would duplicate the same formulas to reflect Stop Times in other cells.

My final result is to have another cell (F1) use the Concatenate formula to have the Start and Stop time shown in one cell as "04:00 - 12:30". The times would change based on the Time formated values entered into the Start and Stop time cells.

I have researched this in the board and found many excellent ways to do the opposite, but not convert Time format to Text format. Any assistance is greatly appreciated.


In excel, I tried to convert numbers to number format, using
format/cells/number from the category list. But it won't take, and stays
text-like. Any ideas?

Hi all,

I've had a long search through your pages to see if this question has been answered before but having browsed through about 50 pages worth of threads I couldn't see anything, but if I am repeating prior information I do apologise.

I've written a macro that is relatively simple. It just takes some information in one format, rearranges it, adds some formatting and performs some calculations. Nothing incredibly fancy but it works fine on my computer.

Now, I need to share this macro with some other people, so basically I've just sent that excel file on to the people that need to use it. Should be fine and in most cases it is, however there is one user who although they can open the file, can't seem to get the macro to run properly.

It seems to get a small way through the macro but then stop with no error messages or any sign that it hasn't completed properly.

I have checked Macro Security level and that is the same as mine, Tools - Add-Ins is the same, In Visual Basic, Tools - References is the same as mine. It is the same Operating system and the same version of Excel.

I have even signed into this person's computer as myself (it's a big company network thing) and tried to run the macro and it works fine, so there is nothing wrong with the hardware.

I've googled and searched and tried everything I can think of but I'm no closer to solving this problem, so if anyone has read through this wall of text and can come up with a possible solution, that would be greatly appreciated to save me from tearing ALL my hair out!

Thanks very much for your time.

I have a spreedsheet that shows some percentages example( 9.98% and 15.87%) I am needing to find a way to hide the percentage sign so that they just show as 9.98 and 15.87. The problem I am having is that are been worked out as a percentage, so changing the format of the cell does not work.
Can anyone help?


Dear Sir,

If any one could give me a solution for this its will be a great help for me.

I am working in a bank and on every day we receive Month to date data of Loans and advances made by every branch with Region wise total and manager wise total. With Sum of loan and count of loan. In our MIS format the in A coulum branches are sorted and listed in a sequence with sub total Region. I have data where if if do the pivot and change the data the out put should be displayed accordingly in the MIS format. Can any one help me how can we do this or is there any other office addins/softwares are available if so the data is changed on a daily basis and if we do the pivot it will automatically copy the data to the MIS format.


I have imported a DBF file into Excel and have a column of dates that are missing the leading zero on single didgit months. When I try to us the custom format of mm/dd/yyyy it doesn't work (interestingly, after I select that format if I click on an individual cell it changes to the right format).

Does anyone know a better way to do this?

Thanks in advance!

How I Can Maintain The Stock Register On Excel Sheet By Date Wise ?

But I do not want to insert any sheet for different dates & also the format will not be copied & paste in the same sheet. Just at the place of Date the date will be changed & the datas will be entered manually for each day.

In future, when I shall put the date, the datas will show that particular date's datas only.

Can anyone help me ?

Hi, this is something so simple that I have forgotten how to do it.
I want F3 to turn yellow if someone selects "Yes" from a drop down list in cell E3, then F3 has no fill once data is entered into it. And F3 turns Black if E3= no selected from the list. Or F3 turns red if E3 contains "TBC"

so in summary,

if E3="Yes", then F3 conditional format to Yellow until data is entered in it.
if E3="No", then F3 conditional format to Black
if E3="TBC", then E3 & F3 conditional format to Red until E3 is changed to
"Yes" or "No" at a later time.

Thanks in Advance for the help


I have a sheet which has the start, stop and time taken for lunch breaks.

I want to calculate the total time worked such that i have the hours worked. So if i worked 7 hours and 30min then the total time would be 7.5hrs. But i am not sure how to take into account the lunch break time (see enclosed sheet).

anyone have any ideas?

Is there an on error exit sub command. I would like my Macro to just stop running if there is an error instead of an error message popping up. Thanks in advance

Hi Guys,

Could you be so kind as to provide some code that will enable me to display a text box on a userform rounded up to 1 decimal place.

Where am I going wrong....
it calculates the number entered in textbox1 and divides it by a value that changes in cell O26 but the answer is in about 8 or more decimel places.
Only need like 65.3 as an answer not 65.277756942

This is the code ive used.

Private Sub CommandButton1_Click()

TextBox2.Value = Val(TextBox1.Value) / Range("O26").Value

End Sub

I know this question has been asked a bajillion times, so I apologize for the redundancy.

I am working with an Excel spreadsheet and saving it as a .csv file in order to upload to an application that parses out the .csv data as transactions. The system requires .csv files, so this is how I need to save my doc (with this extension). I have been successful at preventing Excel from coverting that long number into scientific format. I have saved as a TXT file, pasted the longer number and it displays correctly. That is all good. But I have to save as a .csv. So if I do that, close the Excel window, and then open again (as the .csv file), the numbers are back to being displayed in scientific format. I have tried creating an Excel doc from scratch and entering text in Text format, to see if this created a cleaner file. But again, the second I save as .csv, close the window and then open that file up again, that dang scientific format is back.

Does anyone have any idea of how to work around this? Once I have successfully gotten the numbers to display as the long-chain number, how can I get them to "stick" so that they don't revert back to scientific format when I reopen the file?

Thanks so much for your help!

I am trying to insert a range of cell in the body of an outlook email with the same format. The code I am using now is below and it does insert anything in the email body.


Sub Mail()
Dim OutApp As Object
 Dim OutMail As Object
 Set OutApp = CreateObject("Outlook.Application")
 Set OutMail = OutApp.CreateItem(0)
 On Error Resume Next
 With OutMail
 .To = ""
 .CC = ""
 .BCC = ""
 .Subject = "Burden Report"
 .Body = ActiveSheet.Range("A1:D12")
 .Attachments.Add ("C:\Documents and Settings\cbelcher\Desktop\Burden Report.xls")
End With
 On Error GoTo 0
 Set OutMail = Nothing
 Set OutApp = Nothing
 Set objMsg = Nothing
End Sub

I'm trying to format a worksheet to show how many days overdue certain tasks are, and running into a couple of issues. The sheet is set up with Due Dates in Column A, Days Overdue in Column B, and Date Completed in Column C. My first thought was just to use as simple a formula as possible in Column B =Today()-A2. This worked alright for tasks that already had Due Dates assigned, but if Column A was blank I'd get a high number in Column B. I also realized that tasks will continue to show as overdue even after I enter the completed-on date in Column C. Is there a relatively simple way to tackle this formula? Thanks in advance for suggestions. (I've attached an example with the column headings I want to use.)

Thnx for your help man. Now I have another situation.

I have the following:

1. Login form containing username and password fields.
2. Data entry form

I want to do the following:

1. Coding for username and password fields, which, If the login is successful, takes me to DATA Entry Form, Otherwise shows message "Invalid Login".

Thanks in anticipation.

How can i solve a debugger error that states "run-time error '9'...Subscript out of range.

for a search box code provided by Joe Was

I'm trying to use conditional formatting to highlight phone calls that came in between certain hours.

The call times are in the custom format h:mm, although it could easily be changed to an Excel time format. I'm using Excel 2002. I want the cell to have a different fill color if it falls within particular time frames.

Example: If the call came in between 22:00 and 23:59 color is light green.
If the call came in between 23:59 and 08:00 the color is yellow.

Example spreadsheet is attached.

Thanks in advance.

Hi guys,

would really appreciate anyones help with this.

I have a column full of text-formatted fractions...


etc, etc.....the column is very long!!

I need to convert these to actual fractions...ones I can add to equations, allowing me to multiply and add.

If I highlight the column and goto "format Cells" and change to fraction, the values still stay in the left of the cell.....its only when I manually click on each individual cell, then tick the little green tick, does the cell validate, and the value in the cell moves to the right (and is therefore a proper value).....problem is I have to keep doing this for each individual cell.....and I have 70000+ cells in this column!

Any suggestions on how I could speed this up?


How do I code a custom format to show 0% as a dash? I know how to make it blank, but I don't really want formulas are quite complex already so I'm not sure I want to do it as part of the formula...thanks!

From limited experience I know that excel calculates dates via serial numbers.

I have formulas to add a number of days to a cell containing an entered date and display the resulting new date (ie. 03/01/2011 (c34)+11 = 03/12/2011)

I am seeking to leave resulting formula cell blank until a date is entered in the input cell. Currently when the input cell is empty the formula cell obviously displays 1/11/1900 using the above example.

What conditional format would achieve leaving the formula cell blank until date data in entered into the source cell?

Hopefully a simpler question for your experience level than mine.

I'm having a problem in a workbook with several ActiveX command buttons. I had been using the form control buttons to run macros, but the boss wanted each button to have it's own, different color. So I removed the form control buttons and created new ActiveX command buttons. I got into the button properties and set the background colors. I added the _Click code to run the macros when the user clicked the buttons.

All of the buttons were working fine. Then I saved and closed the workbook and went to lunch. Now when I open the workbook, the buttons don't work! When I click them nothing happens. They appear frozen. They don't even seem to click. No error message. Nothing.

If I right-click the button in Design Mode and select Properties, I get sheet properties not the button properties. I can't seem to locate the command button properties any longer. I still see the button name "cmdButtonGetInfo" and "=EMBED("Forms.CommandButton.1","") in the name box and formula bar. The odd thing is if I create a new button it works fine until I save and close the file. When I reopen the file none of the buttons work.

It's like the buttons are being disabled when I close or open the file. Any suggestions?

Related pages

how to make a attendance sheet in excelconverting kilos to pounds and stonesexcel reference another workbookhow to normalize in excelexcel vba iferrorexcel pivot table count ifgrowth formula in exceltick mark in excelexcel copy macrointernetexplorer.application vbavlookup compare two sheetshow do i get a tick in excelremove duplicates in excel 2007convert est to zuluexcel combinvba word tablesconcatination in excelr1c1 reference styleexcel family tree templatenested function in excelfinding the median in excelexcel solver passwordms access inputboxvba scatter plotopening accdb fileswhat does round to the nearest dollar meanhow to calculate percentage on excel sheetamortization schedule excel 2007hour calculator excelexcel vacation templatehow to apply validation in excelconvert milliseconds to seconds formulamatrix algebra excelbarcode scanner excelfind duplicates in excel spreadsheetopenfiledialog filter multiple extensionsvolume of horizontal cylinder formulaexcel sumif colorhow many rows and columns in excel 2007finding variance in excelvba dir commandexcel workbook tabsexcel password protect cellsexcel graph macroexcel password to open removerpst convert to eststacked bar chart in excel 2010excel cell character countstock maintain format in excel sheetweibull paper excelhow to ungroup worksheets in excelhow to lock first row in excelquery table vbanull idispatch passed to autowrapexcel kmlexcel &textexcel spreadsheet for timesheetcolumemultiply two columns in excelvba code to transfer data from one sheet to anotherexcel sorting macrohow to unprotect workbook in excel 2007lookup with multiple criteriaformula for cell color in exceldeveloper tab in excel 2007excel formula for percent changevba checkboxkb to gb calculatorline of credit amortization schedule excelword wrap in excelexcel bubble chart multiple seriesexcel vba matchvlookup issuesindirect cell referencerule of 78 loan calculatormacro remove blank rowslotto syndicate template