I copied and pasted code in a new module and it's not running or recognizing the code.
I copied and pasted code in a new module and it's not running or recognizing the code.
This is code in a standard module, you need to call to the procedure for it to run. How are you doing that?
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
I opened another module and just said Call ConditionalFormatDelink. It says I have an ambiguous name
How do you do that?
Is this what your talking about
The general syntax when calling another procedure is (in your case) simplyHowever, you also need to define rRng ...Please Login or Register to view this content.
When you say define rng do you mean just put rRng As Range before I call the code
For example:orPlease Login or Register to view this content.
ArtikPlease Login or Register to view this content.
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
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
Yes, I forgot about that. Sorry
Hi I attached the code.
The XLSX file certainly does not contain the code.
Artik
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.
Sorry sent you the wrong file
I can try that. Thanks.
The clear format wouldn't work
There are several .xlsx wb's I have one with all the code. I want the clean report to go to a specific workbook
As cytop said, there is no conditional formatting in the example sheet, so there will be no fun with this code either.
Artik
Here is the sheet that get copied in paste to the main report
Works perfectly well for me...
Attachment 782673
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
I used windows("book1.xlsx").activate to try to go to the report
Can you get that Macro to work on this .xlsx file
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]
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.
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.
Here is one of the wb with the conditional values
I solved this issue. Thanks for your help
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks