VBA save as error & VBA Paste in UPPER CASE

tcorcoran15

New Member
Joined
Feb 16, 2017
Messages
22
I have created the following VBA macro in excel. The macro works fine until I get to the save as section at the end.

I have used the same code in other excel spreadsheet and its saves perfectly, although I get the following error message when I try to do it within this spreadsheet:

"Compile error:

Wrong number of arguments or invalid property assignment" It makes reference to the word format.

Is it something it doesn't like about the macro above?

Also, whilst I'm here I may as well get this completed haha.

Does anybody know how to paste as UPPER CASE within the VBA code. I have noted below which section I would like this to occur.

Any help is greatly appreciated. :-)


Code:
Sub Format()
'
' Format Macro
'
    Sheets("Data Dump").Select
    Dim N As Long
        N = Cells(1, 1).End(xlDown).Row
        Range("D1:D" & N).Select
    Selection.Copy
    Sheets("Customers").Select
    Range("A1:B1").Select
    ActiveSheet.Paste
    
    ActiveSheet.Range("$A$1:$A$10000").RemoveDuplicates Columns:=1, Header:=xlNo
    ActiveSheet.Range("$B$1:$B$10000").RemoveDuplicates Columns:=1, Header:=xlNo
    
     'With ThisWorkbook
        '.Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = "Run"
    'End With
    
    With Sheets("Customers")
        Set Rng = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row)
        For Each R In Rng
            'Code to follow
            
    Sheets("Customers").Select
        Set customer = .Range("B2")
   
    
    Sheets("Data Dump").Select
    ActiveSheet.Range("$A$1:$BU$15001").AutoFilter Field:=4, Criteria1:=customer
    
    Range("A1:BU500").Copy
    Sheets.Add After:=ActiveSheet
    ActiveSheet.Paste 'This is where I would like to paste as UPPER CASE
    
     Set wh = Worksheets(ActiveSheet.Name)
            ActiveSheet.Name = wh.Range("Q2").Value
            
    Sheets("Customers").Select
    Range("B2").Delete
    
    Next R
    
    Cells.Select
    Selection.Delete Shift:=xlUp
    
    
    Sheets("Data Dump").Select
    Selection.AutoFilter
    
    
        
    End With
    
    Application.DisplayAlerts = False
    Sheets("Data Dump").Delete
    Sheets("Customers").Delete
    Application.DisplayAlerts = True


    End Sub
    
    Sub SaveAs()


        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs ("X:\Company\File\File - Live\Reports\Credit Control Files\Contracts File " & Format(Now(), "DD-MMM-YYYY hh mm") & ".xlsx")
        Application.DisplayAlerts = True
        
    End Sub
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
For the UPPER CASE bit :

Code:
ActiveSheet.Paste 'This is where I would like to paste as UPPER CASE
[A1:BU500] = [INDEX(UPPER(A1:BU500),)]
 
Upvote 0
For the SAVEAS bit, try :
Code:
ActiveWorkbook.SaveAs "X:\Company\File\File - Live\Reports\Credit Control Files\Contracts File " & Format(Now(), "DD-MMM-YYYY hh mm") & ".xlsx", FileFormat:=51
 
Upvote 0
The error has appeared again, really doesn't like the format part. When I put the same save as code in other spreadsheets it works perfectly which makes me believe it doesn't like something in the macro above.

Is there a way to disable the macro above during that stage of the VBA?
 
Upvote 0
Name the macro something other than Format.
(Your save macro is calling the Format macro.)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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