+ Reply to Thread
Results 1 to 2 of 2

Receiving 400 error

Hybrid View

  1. #1
    Registered User
    Join Date
    06-24-2015
    Location
    Wisconsin
    MS-Off Ver
    Excel 2013
    Posts
    49

    Receiving 400 error

    I'm receiving a "400" error when trying to run one of my macros.

    So I decided to step through my code and am getting the below error:

    Run-time error '1004': Application-defined or object-defined error

    The error is happening right after this section of code

    .Range("A1:G1").Delete
    Here is the whole VBA.

    Sub FormatSave()
    
    'Convert to format desired
    Dim WS1 As Worksheet
    Dim Rand As Long
    Set WS1 = Worksheets("N")
    Dim lRow1, lRow2 As Long
    Dim rcell As Range
    
    'lRow1 = N.Range("A" & Rows.Count).End(xlUp).Row
    'lRow2 = Y.Range("A" & Rows.Count).End(xlUp).Row
    
    Set rcell = Columns(1).Find("Steps", LookIn:=xlValues, lookat:=xlWhole)
        If Not rcell Is Nothing Then
            Rows(rcell.Row).Resize(12).Delete  'CAN REPLACE .Hidden with .Delete if that suits you better
        End If
    Set rcell = Nothing
    
    If Not WS1 Is Nothing Then
    With WS1
    
        ' Delete first row
        .Range("A1:G1").Delete
        
        ' CustomerID
        .Range("A:A").ColumnWidth = 7
        
        ' Amount
        .Range("B:B").ColumnWidth = 18
        
        ' Item Type
        .Range("C:C").ColumnWidth = 12
        
        ' Reference Nbr
        .Range("D:D").ColumnWidth = 30
        
        ' Accounting Date
        .Range("E:E").ColumnWidth = 8
        
        ' Term
        .Range("F:F").ColumnWidth = 4
        
        ' Reversal Ind
        .Range("G:G").ColumnWidth = 1
    
        
    
    ESTFileDate = Format(Now, "MMDDYYYY")
    
    ' Save File as XLS
        ChDir "\\test\UWCOL\FA_files"
        .SaveAs Filename:= _
            "\\test\UWCOL\FA_files\DisbPos_" & ESTFileDate & ".xls", FileFormat:= _
            xlPrinter, CreateBackup:=False
    
    ' Save File as PRN
        ChDir "\\test\UWCOL\FA_files"
        .SaveAs Filename:= _
            "\\test\UWCOL\FA_files\DisbPos_" & ESTFileDate & ".prn", FileFormat:= _
            xlTextPrinter, CreateBackup:=False
    
    ' Save File as DAT
        ChDir "\\test\UWCOL\FA_files"
        .SaveAs Filename:= _
            "\\test\UWCOL\FA_files\DisbPos_" & ESTFileDate & ".dat", FileFormat:= _
            xlTextPrinter, CreateBackup:=False
            
    End With
    
    End If
    
    
    With Sheet1
    
    ' Save File as XLS
        ChDir "\\test\UWCOL\FA_files"
        .SaveAs Filename:= _
            "\\test\UWCOL\FA_files\DisbAll_" & ESTFileDate & ".xls", FileFormat:= _
            xlPrinter, CreateBackup:=False
    
    End With
    
    End Sub

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Receiving 400 error

    Hello mklindquist0815,

    Try:
    .Range("A1:G1").ClearContents
    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Using =SPELLNUMBERTOENGLISH; receiving NAME? error.
    By Martin79 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-07-2016, 01:49 PM
  2. receiving the 1004 error code.
    By starlev in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2015, 10:00 AM
  3. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  4. [SOLVED] Name Split receiving #VALUE! error
    By kazphilips in forum Excel General
    Replies: 3
    Last Post: 06-22-2012, 01:58 PM
  5. Receiving Object Error
    By pawebb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2007, 07:11 PM
  6. [SOLVED] Renamed tab .xls>3 receiving a error but can't fix
    By TB in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-30-2006, 11:40 PM
  7. Trying to open a file and receiving this error.
    By John J. in forum Excel General
    Replies: 3
    Last Post: 03-11-2005, 02:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1