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
78
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: 3
  • 2.JPG
    2.JPG
    50.8 KB · Views: 3

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,171
Office Version
  1. 2016
Platform
  1. Windows
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
 

Dave01

Board Regular
Joined
Nov 30, 2018
Messages
78
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.
 

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,171
Office Version
  1. 2016
Platform
  1. Windows
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
 
Solution

Dave01

Board Regular
Joined
Nov 30, 2018
Messages
78
wow it works great, didnt think it would work as I thought it would just start at the top again,

thank you so much.
 

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,171
Office Version
  1. 2016
Platform
  1. Windows
wow it works great, didnt think it would work as I thought it would just start at the top again,

thank you so much.
Thanks for update
 

Watch MrExcel Video

Forum statistics

Threads
1,130,048
Messages
5,639,769
Members
417,111
Latest member
buyukbang

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
Top