Hi,
Still a newbie regarding VBA, I have searched Google for 2 days without finding an answer to the issue below. In the example attached, I have aggregated pieces of codes found here and there but I have 1 main and 2 smaller issues left.
My final goal is different from the example attached; I have just created a simpler version focused on the issue. In this example, I would like to color the column where the button is present. Problem is that I have to select a cell in the column before, instead of just clicking the button.
How the example works:
In "Tools", press the picture Temporary. This will:
1-Create a "ToCheck" sheet
2-Copy the data from "TEMP" to "ToCheck", inserting an intermediary column (i+1) after each column source (i)
3-Select in the first row the cells i and i+1, then creating a button matching the size of the 2 cells
4-Write the identical code for each different button (coloring the column)
1: I had to do that for an unknown reason. "TEMP" results originally from an import that I don't control, and if I don't work on a copy then the macro will take a very long time to run (I guess due to the formatting of the source file)
2&3: This is a very irritating part. To make things simpler, I tried to rewrite the macro by removing the intermediary column. But by doing so, then the buttons are created but they don't work at all! ...and I can't figure out why.
Problems:
-My main one how should the code be modified to color the 2 columns of the pressed button?
-If I want to reset the file by inserting the line "Sheets("ToCheck").Delete", it doesn't work even if I confirm the request. What have I understood wrongly?
-It is nowhere in the file, but I have also been looking for a way to reset the Private sub commands created for each button. In my master file, I can run the original macro several times, which will therefore create duplicated "Private Sub Button_XX_Click()" commands and will generate issues. Currently, I have to select and erase the code manuallyIs there a way (and I am sure that there is one) to reset the code with a command?
I have tried to make things as easy as I could, I hope that it will be enough.
Thank you for your time.
ForumTestButton.xlsm
Bookmarks