Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50190

[SOLVED] Inconsistent complaint of "Type Mismatch"

$
0
0
I'm running a Macro that saves a file under a new file name on the click of a button. The new file name is decided by what the use types in to certain cells. I've been running with on multiple documents for months now, and decided to make a new version in which the entry in cell K5 needed to be a number instead of a string. NOW, if I try to click-to-save, I get a "Type Mismatch Error". This only happens if I type a number in K5. This is extra puzzling because I have always been typing number in cells E5, F5, and G5, an they save into the title of the new document successfully and consistently. Below is the code that I'm using. Any ideas?

Code:

Sub SaveAs_Supplier()

Dim PART As String
Dim HAND As String
Dim SHIFT As String
Dim MACHINE As String
Dim OPER As String
Dim MONTHDATE As String
Dim DAYDATE As String
Dim YEARDATE As String
Dim FullFileName As String

Dim NewFileName As String

MONTHDATE = ThisWorkbook.Worksheets("Supplier Inspection").Range("E5").Value
DAYDATE = ThisWorkbook.Worksheets("Supplier Inspection").Range("F5").Value
YEARDATE = ThisWorkbook.Worksheets("Supplier Inspection").Range("G5").Value
PART = ThisWorkbook.Worksheets("Supplier Inspection").Range("H5").Value
HAND = ThisWorkbook.Worksheets("Supplier Inspection").Range("I5").Value
SUPPLIER = ThisWorkbook.Worksheets("Supplier Inspection").Range("J5").Value
RISER = ThisWorkbook.Worksheets("Supplier Inspection").Range("K5").Value
TOTALRISER = ThisWorkbook.Worksheets("Supplier Inspection").Range("L5").Value

NewFileName = PART + " " + HAND + " " + MONTHDATE + "-" + DAYDATE + "-" + YEARDATE + " " + SUPPLIER + " " + RISER
FullFileName = "Z:\yyyyy\xxxxxx\" & NewFileName & ".xlsm"

ActiveWorkbook.SaveAs (FullFileName)


End Sub


Viewing all articles
Browse latest Browse all 50190

Trending Articles