+ Reply to Thread
Results 1 to 3 of 3

Showing run time error 1004

  1. #1
    Registered User
    Join Date
    05-11-2016
    Location
    india
    MS-Off Ver
    ms office 2019
    Posts
    13

    Showing run time error 1004

    Dear All, i m creating a file which i facing a issue in run the code every time i got the error on below

    I m getting error on this (Shtnames(UBound(Shtnames)) = c.value)

    Sub Print_Printer()

    Dim c As Range
    Dim lastrow, i As Integer
    Dim Shtnames As Variant
    ReDim Shtnames(0)

    lastrow = Sheets("DATA").Columns("H").Cells(Rows.Count).End(xlUp).row

    For Each c In Sheets("DATA").Range("H2:H" & lastrow)
    If c.value <> 0 Then
    Sheets("BILL").Range("E7").value = c.value
    Sheets("BILL").Copy After:=Sheets(Sheets.Count)
    Sheets(Sheets.Count).Name = c.value <======== getting error over there
    Shtnames(UBound(Shtnames)) = c.value
    ReDim Preserve Shtnames(UBound(Shtnames) + 1)
    End If
    Next c

    ReDim Preserve Shtnames(UBound(Shtnames) - 1)
    Sheets(Shtnames).Select

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False

    Application.DisplayAlerts = False
    Sheets(Shtnames).Delete
    Application.DisplayAlerts = True

    End Sub

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello tanwarrahul,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-11-2016
    Location
    india
    MS-Off Ver
    ms office 2019
    Posts
    13

    Re: Showing run time error 1004

    Hi Sir pls help me out to resolve this issue.

+ 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. Replies: 0
    Last Post: 12-16-2014, 10:12 AM
  2. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  3. Addon error : Run-time error '1004': Method 'MacroOptions' of object '_Application' failed
    By jtcoleman in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 02-05-2014, 12:23 PM
  4. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  5. Showing Run-time error "1004" when executing code with thousans of data
    By nigel_12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2013, 07:03 AM
  6. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  7. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05:05 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