Using Active X command Box and Text box to change colours and text, but stuck on changing it back again not sure if I can

Dave01

Board Regular
Joined
Nov 30, 2018
Messages
116
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi,

I have some really simple code which works on the first step, but I cant recall on the second to put it back again. I have only started messing about with control active x boxes, which are pretty cool what you can do with them, and I get the first part to work, but trying to get them back to the original colours at the program start is where I cam unstuck.

So
Pic 1, the text Box is Blue the Parked report control button is blue
Pic 2, the program ran, text = Red, Control box = green

but when the program has finished I would like Pic 2 to go back to Pic 1.

so to get it from Pic 1 to Pic 2 it starts with this, and works great.


Private Sub ParkedPagerReportB2_Click()

FunctionSelectDisplay.Text = "Parked Report In Progress...."
FunctionSelectDisplay.BackColor = RGB(204, 0, 0)
ParkedPagerReportB2.BackColor = RGB(0, 255, 0)

'Call Parked_Report ' on click start the Parked Report

End Sub

Sub parked Report ()

all my other code


*** NOW IM Stuck

end sub.


***
I tried to call the program back but under a different name, I tried SUB, Private Sub, Public Sub, all end in Sub or Function Not Defined in the macro

I put the below back into sheet 9 (settings) but no difference.

Public Sub End_ParkReport()

FunctionSelectDisplay.Text = "Please Select Program...." ' update Digital Display
FunctionSelectDisplay.BackColor = RGB(51, 0, 153)
ParkedPagerReportB2.BackColor = RGB(0, 0, 153)

End Sub



The buttons are on a worksheet called sheet 9(settings) it doesnt seem to work if I put it in a Module, seems it has to sit inside the code bit of the worksheet.
I cant call back the original Private Sub ParkedPagerReportB2_Click() as this would just leave it in its current state, if it worked didnt test it.

so I have no idea how to get the same boxs to change two colours, 1 before the program is ran, and back again after.

Help would be highly appreciated. It would be a shame to scrap the idea because although it serves no really purpose, it does look kind of cool to have.

thanks for any help.

David.
 

Attachments

  • 1.JPG
    1.JPG
    54.4 KB · Views: 8
  • 2.JPG
    2.JPG
    50.8 KB · Views: 8

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
You can use IF condition every time you click the command button

Rich (BB code):
If color = Blue then
   color = Green
Else
   color = Blue
End IF
 
Upvote 0
Hi,

Thanks for the reply, but that solution wouldnt work for what I need it to do, sorry if I confused you, how it works is


you click the command button once, -> the command button changes to Green, "digital Display" turns to red and displays Parked Report In Progress
then does all the other program macro code

when the main code is finishes, it the turns the Digital Display back to blue, changes text back to Select Function, and changes the command button back to blue automatically.

so you only ever press the button once.

thats why when the program finishes I was trying to call the colour change back again to the original colours and text, but thats where I am stuck.

thanks

Dave.
 
Upvote 0
Sorry for not reading carefully. You do not need to create another subroutine to return to original state. It can be in your main sub like this

VBA Code:
Private Sub ParkedPagerReportB2_Click()

FunctionSelectDisplay.Text = "Parked Report In Progress...."
FunctionSelectDisplay.BackColor = RGB(204, 0, 0)
ParkedPagerReportB2.BackColor = RGB(0, 255, 0)

'Call Parked_Report ' on click start the Parked Report

FunctionSelectDisplay.Text = "Please Select Program...." ' update Digital Display
FunctionSelectDisplay.BackColor = RGB(51, 0, 153)
ParkedPagerReportB2.BackColor = RGB(0, 0, 153)

End Sub
 
Upvote 0
Solution
wow it works great, didnt think it would work as I thought it would just start at the top again,

thank you so much.
 
Upvote 0

Forum statistics

Threads
1,223,157
Messages
6,170,418
Members
452,325
Latest member
BlahQz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top