• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Error 13 - type mismatch

Jest4kix

New Member
I am trying to save a file using an incremental numbering system. I think the problem is that I am trying to save a file name (text?) by adding a numerical value - hence the mismatch.
I don't know how to 'match' the two.
Here's my code:


Code:
Sub Savewithnewname()
Dim NewFN As Variant
PosttoRegister
ActiveSheet.Copy
NewFN = "c:\users\testing\desktop\jest4kix\PO" & Range("f4").Value + ".xlsm"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
End Sub

Your assistance would be greatly appreciated as always.
 
Last edited by a moderator:
@ Jest4kix

Welcome here!!

I guess few thing in ur code!
  1. There's might be for loop is missing.
  2. Is PO is a folder then "\" is missing inside it.
  3. What is PosttoRegister & NextInvoice

Pls share the sample workbook so that we may get corrected to it for u.

Don't forget to tag the code while posting the same in body of the thread.
 
Hi !

To match both, don't use + but just & (concatenate operator) …
Thank you - that was it (the ampersand instead of the +.

Next question
When this macro calls the next macro (which should increase the file # by one), I get an Error 1004 Method Range of Object Global failed.
Here's the code:

Code:
Sub NextInvoice()
Range("f4").Value = Range("f").Value + 1
Range("a24:g41").ClearContents
End Sub

(F4 is the cell that contains the number I want to increment by 1)
 
Last edited by a moderator:
@ Jest4kix

As i already said, you must to tag the code!!

Is this..

Code:
Sub NextInvoice()
Range("f4").Value = Range("f4").Value + 1
Range("a24:g41").ClearContents
End Sub
 
@ Jest4kix

As i already said, you must to tag the code!!

Is this..

Code:
Sub NextInvoice()
Range("f4").Value = Range("f4").Value + 1
Range("a24:g41").ClearContents
End Sub

As message warned, just a bad Range
Thanks Marc L - can you tell me what is "bad" about the range? It is just a single cell that I want to increment by 1. Maybe no quotation marks? Sorry if I sound totally inept, but I have not done any coding in years, and am obviously very rusty!!
 
Thank you for your assistance above - I have everything working the way I wanted.
Can someone please advise me of the syntax for saving a file to a network. I've created the spreadsheet on the C:\ drive, but now I need to make it public.
 
Back
Top