Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2022, 10:40 PM
Basse Basse is offline ActiveX ComboBox showing different texts based on value Windows 10 ActiveX ComboBox showing different texts based on value Office 2021
Novice
ActiveX ComboBox showing different texts based on value
 
Join Date: May 2022
Posts: 4
Basse is on a distinguished road
Question ActiveX ComboBox showing different texts based on value

Hello,


I am new to VBA and I'm looking to create a activeX ComboBox dropdown list where each value makes a different text text visible. My idea is to put 3 different texts and bookmark them with Text1, Text2 and Text3 and then when I choose 1 in the ComboBox, Text1 is visible while Text2 and Text3 are hidden. I'm looking to create an IF statement, something like "If ComboBox value is equal to 1, Text1 is visible while Text2 and Text3 are hidden" Is there any way to do this? I have managed to do it with the "non"-activeX combobox, but I would find it more suitable with the actievX ComboBox.

Here is what I done so far in the VBA script and I attach the file down below:

Private Sub ComboBox1_DropButtonClick()

ComboBox1.List = Array("1", "2", "3")

End Sub

Best regards
Attached Files
File Type: docm Dropdown.docm (21.3 KB, 6 views)
Reply With Quote
  #2  
Old 05-11-2022, 11:38 PM
Basse Basse is offline ActiveX ComboBox showing different texts based on value Windows 10 ActiveX ComboBox showing different texts based on value Office 2021
Novice
ActiveX ComboBox showing different texts based on value
 
Join Date: May 2022
Posts: 4
Basse is on a distinguished road
Default

I think I managed to find a solution for this, so if anyone is interested, here's my solution:


Private Sub ComboBox1_DropButtonClick()

ComboBox1.List = Array("1", "2", "3")

If ComboBox1.Value = "1" Then
Bookmarks("Text1").Range.Font.Hidden = False
Bookmarks("Text2").Range.Font.Hidden = True
Bookmarks("Text3").Range.Font.Hidden = True
End If

If ComboBox1.Value = "2" Then
Bookmarks("Text1").Range.Font.Hidden = True
Bookmarks("Text2").Range.Font.Hidden = False
Bookmarks("Text3").Range.Font.Hidden = True
End If

If ComboBox1.Value = "3" Then
Bookmarks("Text1").Range.Font.Hidden = True
Bookmarks("Text2").Range.Font.Hidden = True
Bookmarks("Text3").Range.Font.Hidden = False
End If

End Sub
Reply With Quote
Reply

Tags
activex, combobox, show/hide

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adjust userform layout based on combobox selection jrooney7 Word VBA 3 09-16-2018 07:23 PM
ActiveX ComboBox showing different texts based on value ActiveX Controls not showing when pasted from Word to Email Body Skahtn Word 1 09-06-2017 02:41 PM
Inserting a particular image based on a combobox selection LeonieD PowerPoint 2 06-27-2014 05:39 PM
how to populate textbox based on combobox selection in word IvanGeorgiev Word 1 02-21-2013 07:32 PM
ActiveX ComboBox showing different texts based on value how to populate textbox based on combobox selection in word IvanGeorgiev Word VBA 1 02-21-2013 07:28 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:49 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft