Sub or function not defined

Mfana

New Member
Joined
Mar 5, 2018
Messages
8
Hi

I'm trying to compile a code for customised invoicing on excel using macros and get an error. Help on the missing link below

Regards
Mfana

Code:
Sub nextInvoice()
Range("L9").Value = "In00" & Text(Now(), "0") & L9.Value + 1
Range("e22").ClearContents
Range("g22").ClearContents
Range("L22").ClearContents
Range("C25:f36").ClearContents
End Sub


Sub SaveInvWithNewName()
    Dim NewFN As Variant
    'Copy Invoice to a new workbook
    ActiveSheet.Copy
    NewFN = "c:\Documents\Housing\hsInv" & "In00" & Text(Now(), "0") & L9.Value & ".xlsm"
    ActiveWorkbook.SaveAs NewFN, FileFormat: xlOpenXMLWorkbookMacroEnabled
    Print2
    ActiveWorkbook.Close
    NewInvoice
    ActiveWorkbook.Save
End Sub


Sub Print2()
For I = 1 To 2
ActiveSheet.PrintOut
Next I
End Sub


Private Sub Workbook_Open()


End Sub
 
Last edited by a moderator:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the forum.

Text is a worksheet function, not VBA. Use Format$ instead.
 
Upvote 0
Rory

L9 is a merged cell & the result is object required "423", pls advise, desperate
Code:
Sub nextInvoice()
Range("L9").Value = "In00" & Format$(Now(), "0") & L9.Value + 1
Range("e22").ClearContents
Range("g22").ClearContents
Range("L22").ClearContents
Range("C25:f36").ClearContents
End Sub




Sub SaveInvWithNewName()
    Dim NewFN As Variant
    'Copy Invoice to a new workbook
    ActiveSheet.Copy
    NewFN = "c:\Documents\Housing\hsInv" & "In00" & Format$(Now(), "0") & L9.Value & ".xlsm"
    ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbookMacroEnabled
    Print2
    ActiveWorkbook.Close
    NewInvoice
    ActiveWorkbook.Save
End Sub




Sub Print2()
For I = 1 To 2
ActiveSheet.PrintOut
Next I
End Sub




Private Sub Workbook_Open()




End Sub
 
Last edited by a moderator:
Upvote 0
It should be this:

Code:
Range("L9").Value = "In00" & Format$(Now(), "0") & Range("L9").Value + 1
 
Upvote 0
Sub or function not defined, it seems 1 is missing a fundamental puzzle
Rich (BB code):
Sub mergeCellsAndCenter()
 
    With Workheet("Invoice")("Merge Cells").Range("e22:f22", "g22:i22").Merge
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .Merge
    End With
 
End Sub
 
Last edited by a moderator:
Upvote 0
Please learn to use code tags when posting code.

It's Worksheets, not Workheet. If the ("Invoice")("Merge Cells") part is an attempt to refer to two sheets, that won't work. You need to process them separately.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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