ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform: Enter combobox value unless textbox contains data (https://www.excelbanter.com/excel-programming/360262-userform-enter-combobox-value-unless-textbox-contains-data.html)

smplogc[_4_]

Userform: Enter combobox value unless textbox contains data
 

Hi again. This forum has been invaluable.

I'd like to know the piece of code for a userform that would enter the
combobox value by default unless any data is present in a textbox (as a
"specify other" choice not present in the combobox).
Thanks!!!!


--
smplogc
------------------------------------------------------------------------
smplogc's Profile: http://www.excelforum.com/member.php...o&userid=33887
View this thread: http://www.excelforum.com/showthread...hreadid=537875


Tom Ogilvy

Userform: Enter combobox value unless textbox contains data
 
With userform1.Combobox1
.Style = fmStyleDropDownCombo
.MatchRequired = False
.Value = "Specify Other"
End With

--
Regards,
Tom Ogilvy


"smplogc" wrote in
message ...

Hi again. This forum has been invaluable.

I'd like to know the piece of code for a userform that would enter the
combobox value by default unless any data is present in a textbox (as a
"specify other" choice not present in the combobox).
Thanks!!!!


--
smplogc
------------------------------------------------------------------------
smplogc's Profile:

http://www.excelforum.com/member.php...o&userid=33887
View this thread: http://www.excelforum.com/showthread...hreadid=537875




smplogc[_6_]

Userform: Enter combobox value unless textbox contains data
 

Thanks Tom!

I think I didn't explain myself clearly though. I'm talking about a
userform with a combobox, a textbox, and an "Enter" command button. I
want the commandbutton to always enter the combobox value unless the
textbox contains data that was inputted by the user. :)


--
smplogc
------------------------------------------------------------------------
smplogc's Profile: http://www.excelforum.com/member.php...o&userid=33887
View this thread: http://www.excelforum.com/showthread...hreadid=537875


smplogc[_5_]

Userform: Enter combobox value unless textbox contains data
 

Thanks Tom!

I think I didn't explain myself clearly though. I'm talking about a
userform with a combobox, a textbox, and an "Enter" command button. I
want the command button to always enter the combobox value unless the
textbox contains data that was inputted by the user. :)


--
smplogc
------------------------------------------------------------------------
smplogc's Profile: http://www.excelforum.com/member.php...o&userid=33887
View this thread: http://www.excelforum.com/showthread...hreadid=537875


smplogc[_7_]

Userform: Enter combobox value unless textbox contains data
 

Thanks Tom!

I think I didn't explain myself clearly though. I'm talking about a
userform with a combobox, a textbox, and an "Enter" command button. I
want the command button to always enter the combobox value unless the
textbox contains data that was inputted by the user. :)


--
smplogc
------------------------------------------------------------------------
smplogc's Profile: http://www.excelforum.com/member.php...o&userid=33887
View this thread: http://www.excelforum.com/showthread...hreadid=537875


Tom Ogilvy

Userform: Enter combobox value unless textbox contains data
 
Private Sub Commandbutton1_click()
Dim sh as Worksheet
set sh = Worksheets("Sheet1")
With Userform1
if .Textbox1.Text = "" then
sh.Range("B9").Value = .Combobox1.Value
else
sh.Range("B9").Value = .Textbox1.Text
end if
End With
End Sub

--
Regards,
Tom Ogilvy

"smplogc" wrote in
message ...

Thanks Tom!

I think I didn't explain myself clearly though. I'm talking about a
userform with a combobox, a textbox, and an "Enter" command button. I
want the command button to always enter the combobox value unless the
textbox contains data that was inputted by the user. :)


--
smplogc
------------------------------------------------------------------------
smplogc's Profile:

http://www.excelforum.com/member.php...o&userid=33887
View this thread: http://www.excelforum.com/showthread...hreadid=537875





All times are GMT +1. The time now is 09:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com