Results 1 to 7 of 7

Run-time error 1004 with column counter

Threaded View

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    13

    Run-time error 1004 with column counter

    Hello Excel Forum,

    On one worksheet I have a range of column headers. Underneath this range of column headers I'd like to copy and paste values that are calculated in another sheet. In the first step I set a variable equal to the length of the column headings, but I'm getting the run-time error 1004: method range of object worksheet failed. I'm thinking this may be an easy syntax problem but I couldn't find any solutions in the forum or through google.

    This is my command button code:

    Private Sub CommandButton1_Click()
    
    Dim lngCounter As Long
    Dim ws1 As Worksheet
    Dim ws2 As Worksheet
    Dim ws3 As Worksheet
    
    Set ws1 = Sheets("Catch for Port Calc")
    Set ws2 = Sheets("2 - Dashboard")
    Set ws3 = Sheets("18 - Catch and Days at Sea")
    
    For lngCounter = 4 To ws1.Range(6, Columns.Count).End(xlToLeft).Column
      If ws1.Cells(6, lngCounter).Value <> "" Then
        ws2.Range("C3").Value = ws1.Cells(6, lngCounter).Value
        ws1.Cells(7, lngCounter).Resize(150, 1).Value = ws3.Range("C6").Resize(150, 1).Value
      End If
    Next lngCounter
    
    Set ws3 = Nothing
    Set ws2 = Nothing
    Set ws1 = Nothing
    
    End Sub
    My workbook is quite large and still in development so I have copied and pasted the three relevant worksheets to a new document:Modified Workbook for Excelforum.xlsm Let me know if any more information is required.

    Many thanks in advance!
    Griffin
    Last edited by GriffinCarpenter; 09-30-2014 at 09:08 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [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
  2. 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
  3. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  4. 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
  5. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By rich5665@gmail.com 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