+ Reply to Thread
Results 1 to 30 of 30

My code wont run in my module

  1. #1
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    My code wont run in my module

    I copied and pasted code in a new module and it's not running or recognizing the code.
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: My code wont run in my module

    This is code in a standard module, you need to call to the procedure for it to run. How are you doing that?

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: My code wont run in my module

    You would need to call that subroutine from another subroutine and pass it a range. You need to have specified rRng so that the routine has something to work with.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    I opened another module and just said Call ConditionalFormatDelink. It says I have an ambiguous name

  5. #5
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    How do you do that?

  6. #6
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Is this what your talking about
    Attached Images Attached Images

  7. #7
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: My code wont run in my module

    The general syntax when calling another procedure is (in your case) simply
    Please Login or Register  to view this content.
    However, you also need to define rRng ...

  8. #8
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    When you say define rng do you mean just put rRng As Range before I call the code

  9. #9
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: My code wont run in my module

    For example:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    Artik

  10. #10
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    This is what I have, its runs but nothing happens

    Sub cleanReport()
    Dim rRng As Range


    Windows("Blank Compressor Fuel Report.xlsx").Activate
    Set rRng = Range("B5:F74")
    Call ConditionalFormatDelink(rRng)
    End Sub

  11. #11
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: My code wont run in my module

    It is difficult to test VBA code on images.
    BTW. You've been on the forum for a while, so you should know that the code shown in the post should be in [CODE] tags.

    Artik

  12. #12
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Yes, I forgot about that. Sorry

  13. #13
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Hi I attached the code.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: My code wont run in my module

    The XLSX file certainly does not contain the code.

    Artik

  15. #15
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: My code wont run in my module

    From what I can see, that code you posted (in the image) will not do anything. It seems to be just a boilerplate example but the image doesn't show enough to include code that actually does something

    The file you uploaded has no code (XLSX extension) and, from the size listed, it does not contain any conditional formatting (this has an overhead of about 8kb even on an otherwise empty workbook, so if there was conditional formatting it'd be about 16kb)

    Why don't you simply go to the Home tab/Conditional formatting (in the Styles group) and select 'Manage rules' to see if there are any defined for that sheet? If so, you can review them and delete if you want but I'm willing to bet a simple 'Clear/Clear Formats' (whether from the ribbon or via VBA code) will do what you want.
    Last edited by cytop; 06-02-2022 at 10:22 AM.

  16. #16
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Sorry sent you the wrong file
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    I can try that. Thanks.

  18. #18
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    The clear format wouldn't work

  19. #19
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    There are several .xlsx wb's I have one with all the code. I want the clean report to go to a specific workbook

  20. #20
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: My code wont run in my module

    As cytop said, there is no conditional formatting in the example sheet, so there will be no fun with this code either.

    Artik

  21. #21
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Here is the sheet that get copied in paste to the main report
    Attached Files Attached Files

  22. #22
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: My code wont run in my module

    Works perfectly well for me...

    Attachment 782673
    Attached Images Attached Images

  23. #23
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    I'm using several workbooks and only one of them have code. This workbook had the code in it. I don't want to do it in the wb that has the conditional formatting, I just want to do it in the main report with all the code and then clear out the colors for the main report. That's probably why it worked for you

  24. #24
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    I used windows("book1.xlsx").activate to try to go to the report

  25. #25
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Can you get that Macro to work on this .xlsx file
    Attached Files Attached Files

  26. #26
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Here is the code I have to try to activate the wb and run the macro on it
    [Sub cleanReport()
    Dim wb As Workbook
    Set wb = ActiveWorkbook
    Set ws = wb.ActiveSheet
    Dim wbk_A


    Set wbk_A = Workbooks("Blank Compressor Fuel Report.xlsx")
    Workbooks("Blank Compressor Fuel Report.xlsx").Activate

    Call ConditionalFormatDelink(Range("B5:F74"))

    End Sub]

  27. #27
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: My code wont run in my module

    What I don't understand here is why you are blindly trying to get code to run when it is not even needed, or at least that particular code is not needed ... There is no conditional formatting in the workbook you uploaded, nor in the previous workbook and the formatting can be cleared simply by using 'Clear/Clear formats' as shown in the image I uploaded.

    If you do have a workbook with conditional formatting then do you not think it an idea to upload that? I won't take up any more of your time.
    Last edited by cytop; 06-02-2022 at 01:17 PM.

  28. #28
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Sorry I don't think you understand my post. I have 7 .xslx workbooks with conditional formatting. I have a macro that copy and paste certain values to the main report, when they are copied and pasted the conditional formatting isn't carried over only the background color. When I go to the ribbon to clear any rules there is nothing there and clearing still does nothing. So only the .xlsx wb has the conditional values, what I sent you was what happens after the macro to copy and paste values in the main report does. So no you will not see any conditional formatting in the main report you will only see what happens when it is copied and pasted. I'm trying to remove the back color to white. That's why I'm trying to write code to do so. Clearing it isn't working.

  29. #29
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    Here is one of the wb with the conditional values
    Attached Files Attached Files

  30. #30
    Forum Contributor
    Join Date
    10-01-2013
    Location
    United States
    MS-Off Ver
    Microsoft version 365
    Posts
    110

    Re: My code wont run in my module

    I solved this issue. Thanks for your help

+ 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. Place code in userform, module or class module
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2017, 07:04 AM
  2. Import module code to sheets module ?
    By Rmag in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2017, 06:58 AM
  3. [SOLVED] Code locks cells when inserted in sheet module but returns error in standard module
    By yoda66 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2014, 07:39 AM
  4. how to access Sheet module, normal module, Worbook module to type code
    By alibaba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2009, 07:51 AM
  5. Replies: 4
    Last Post: 12-11-2005, 08:00 PM
  6. Run worksheet module code from workbook module?
    By keithb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2005, 12:05 AM
  7. Replies: 1
    Last Post: 04-10-2005, 07:07 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