VB Userform help

hail11

Board Regular
Joined
May 3, 2007
Messages
199
i have a label 5 in my VBA i would like to be able to swich what it says depending on what the linked page has picked
this is what i need

If sheet 9 range a132 = "Y" then sheet 9 range a133
If sheet 9 range a132 = "N" then sheet 9 range a134
If sheet 9 range a132 = "" then sheet 9 range a133



Please help
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Ron Morris

Active Member
Joined
Oct 18, 2004
Messages
430
Hi,

Add the following code to the event that drives the label caption change:

Code:
If (Sheets("sheet9").Range("A132").Value = "Y" or _
     Sheets("sheet9").Range("A132").Value = "") then
     Label5.Caption = Sheets("sheet9").Range("A133").Value
Elseif Sheets("sheet9").Range("A132").Value = "N" then
     Label5.Caption = Sheets("sheet9").Range("A134").Value
End If

Ron

EDIT: fixed Code tags - Moderator
 

hail11

Board Regular
Joined
May 3, 2007
Messages
199
how can i make if = Y or "" make the font black
but if it is N then red font?
 

hail11

Board Regular
Joined
May 3, 2007
Messages
199
i have
Private Sub Label5_Click()
If (Sheets("sheet8").Range("C179").Value = "Y" Or _
Sheets("sheet8").Range("C179").Value = "") Then
Label5.Caption = Sheets("sheet8").Range("B182").Value
ElseIf Sheets("sheet8").Range("C179").Value = "N" Then
Label5.Caption = Sheets("sheet8").Range("B183").Value
End If

End Sub

It brings up a debug error and i just want to look at it not have to click on it
 

hail11

Board Regular
Joined
May 3, 2007
Messages
199
ok i have this
Private Sub userform_Initialize()
Me.Label5.Caption = Worksheets("Sheet8").Range("b184").Value
End Sub

this is what i needed
 

Forum statistics

Threads
1,181,416
Messages
5,929,790
Members
436,694
Latest member
dpatete

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