+ Reply to Thread
Results 1 to 3 of 3

Run-time error 1004 in Excel Macro

  1. #1
    Registered User
    Join Date
    03-15-2017
    Location
    Malaysia
    MS-Off Ver
    Microsoft 2010
    Posts
    24

    Run-time error 1004 in Excel Macro

    I am new to scripting and I am trying to improve my previous code. The code works to change row and height of the cells in regards of the user input. The code is working just fine, except when I input number less than 5 characters inside the text box. It keeps on getting this error : "Run- time error '1004' Unable to set the ColumnWidth property of the Range class". I tried using On Error Resume Next but it didn't works. These are the code:

    Please Login or Register  to view this content.
    I kept on getting error in this line "Columns.ColumnWidth = pixcol". Please help.
    Thank you.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Run-time error 1004 in Excel Macro

    what do you think is cm1 value? as is, it would be 0 (same is true for cm2), so pixcol after convert of measurement will be negative (-0.5771).
    Also note that the way you declare your variables at the moment, cm1 and cm2 are Variant
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Registered User
    Join Date
    03-15-2017
    Location
    Malaysia
    MS-Off Ver
    Microsoft 2010
    Posts
    24

    Re: Run-time error 1004 in Excel Macro

    Hi all. I can figure out the answer already. I just insert error handling code to my previous code. It looks like this:
    Please Login or Register  to view this content.
    Thank you for your kind assistance.

+ 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: 10-20-2014, 05:33 PM
  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. excel macro run time error '1004'- Application defined or object defined error
    By kmadan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 09:51 AM
  4. Replies: 0
    Last Post: 03-25-2014, 10:25 AM
  5. Macro Enabled Excel - Run Time Error 1004
    By sweetdivya in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2013, 05:50 AM
  6. Excel Macro Error - Run time error 1004 - Paste method of worksheet class failed
    By kvflynn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2012, 10:51 AM
  7. Run Time error 1004 in Excel Macro
    By Samik23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2006, 09:32 AM

Tags for this Thread

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