+ Reply to Thread
Results 1 to 2 of 2

Runtime error 9 with conditional format macro

  1. #1
    Registered User
    Join Date
    12-22-2011
    Location
    Berlin, Germany
    MS-Off Ver
    Excel 2010
    Posts
    58

    Runtime error 9 with conditional format macro

    Hi. I have a macro that first deletes the present conditional formats on the tab and then creates a new one. When I run the code, I get "Run-time error 9 - Subscript out of range and it highlights the line "Columns("H:H").FormatConditions(Selection.FormatConditions.Count).SetFirstPriority". Why is this happening and how do I fix it? I've tried inserting selection instead of columns("H:H") with no luck. The strange thing is that sometimes (1/5 times) this code runs fine. Any insight would be appreciated. Thanks!

    Please Login or Register  to view this content.

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

    Re: Runtime error 9 with conditional format macro

    If you use the With command, the statements between the With and End with like Range, Columns, Rows, etc should have the . (dot) in front of them.

    Try this
    Please Login or Register  to view this content.
    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]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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