+ Reply to Thread
Results 1 to 10 of 10

Conditional Formatting Macro .LineStyle = xlContinuous error

  1. #1
    Registered User
    Join Date
    05-29-2011
    Location
    Edinburgh
    MS-Off Ver
    Office365
    Posts
    46

    Conditional Formatting Macro .LineStyle = xlContinuous error

    I am trying to create a macro that recreates the conditional formatting each time a cell is dragged and dropped

    As the conditional formatting code is complex, I tried to use Excel's macro recorder to create the code for me.

    A (much reduced) bit of the code is below, which aims to set borders on cells A1:AF11. I have set the formula to be "=TRUE" as all of cells A1:AF11 need to be set in this way [I realise that conditional formatting is not necessary here - the other 30+ bits of code which I haven't posted are "proper" conditional formats!]


    Please Login or Register  to view this content.
    Every time I run it, the line .LineStyle = xlContinuous gives me an error. How can I fix this?

  2. #2
    Registered User
    Join Date
    05-29-2011
    Location
    Edinburgh
    MS-Off Ver
    Office365
    Posts
    46

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    I should have posted the error

    The error is

    run-time error '1004':

    Unable to set the LineStyle property of the Border class


    Also I am using Excel 2007

  3. #3
    Registered User
    Join Date
    12-21-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    69

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    Your requirement is to put border/format A1:AF11 if user changes anything in the sheet?

  4. #4
    Registered User
    Join Date
    05-29-2011
    Location
    Edinburgh
    MS-Off Ver
    Office365
    Posts
    46

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    Basically, yes

  5. #5
    Registered User
    Join Date
    12-21-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    69

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    I do not have access to Excel 2007, not sure why you were using conditional formatting while recording the macro.
    Just try to format the cells using borders/fill color using record macro, that should work.
    Also, the above code did work for me except .TintAndShade = 0.

  6. #6
    Registered User
    Join Date
    05-29-2011
    Location
    Edinburgh
    MS-Off Ver
    Office365
    Posts
    46

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    The reason for it being conditional is that in the final version of the workbook, not all cells need to have the border. I just haven't written the conditional expression yet, as I want to get this part of the code working first before I write the next bit. Easier to debug errors if I take it one step at a time

  7. #7
    Registered User
    Join Date
    12-21-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    69

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    Please use macro recorder again to do the simple cell formating, do not delete any code and check if that works, later make necessary changes in the code, test it and keep adding your building blocks through seperate procedures.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    If your selected range is, cells( A1:AF11),you can reduce the code by removing the selection part of the code

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-29-2011
    Location
    Edinburgh
    MS-Off Ver
    Office365
    Posts
    46

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    THanks, I think the last one sorted it

    thanks both for all your help

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Conditional Formatting Macro .LineStyle = xlContinuous error

    Smeddlesboy,
    I did not even test the code, but seems to work for you and I am glad it does

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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