#1
|
|||
|
|||
Value of Combobox in other userform
Hi
Do any one know how to use a comboxbox value from a userform in several userform? I have set all to public but it don´t help me. I want to use a value from a combobox in a Outlook message, but how? |
#2
|
||||
|
||||
If the userform is open, you can use userformname.comboboxname.Value to return the value. If it will not be open, you have to store the value in a public variable in a normal module.
|
#3
|
|||
|
|||
I have tried to get the value from the combobox and put it in a variable but it alway turn out empty.
Public Sub CommandButton4_Click() bodymailtext = Antal1 & Antal2 & antal5 & TEST1 Dim OutlookApp As Object Dim OutlookMail As Object Set OutlookApp = CreateObject("Outlook.Application") Set OutlookMail = OutlookApp.CreateItem(0) With OutlookMail .To = "Martin.Vibov@peri.dk" ' "Martin.vibov@peri.dk" .CC = "" ' Husk at ændre disse 2 (TO og CC), hvis der skal testet .BCC = "" .Subject = "Fremtidige udsmidninger " .Body = bodymailtext '"Hej Kim og Peter" & vbNewLine & vbNewLine & "Dette er hvad der forventes, at blive smidt ud" & vbNewLine & vbNewLine & _ "Vare" & vbTab & "Antal" & vbTab & "Sti til billeder" & vbTab & "Peri eller Kunde Scrot" & vbTab & "Total KG." & vbNewLine & _ Antal1 & vbTab & Abtal2 & vbTab & "Variabler skal ind her" & vbNewLine & _ "Med Venlig Hilsen" & vbNewLine & "PERI Logistik" .Send End With Set OutlookMail = Nothing Set OutlookApp = Nothing Sheets("Dropdown").Select Unload Me End Sub Public Sub CommandButton1_Click() 'Application.ScreenUpdating = False strbruger = Environ("username") Dato = Date Dato1 = Dato Dato1 = Format(Dato, "ww") If Anden <> "" Then Sheets("Scrap").Range("A3").Value = Anden Sheets("Scrap").Range("B3").Value = AndenQTY 'Sheets("Scrap").Range("C3").Value = "X:\PERI skrot 2015\Peri skrot i ugere\" & Dato1 & "\" With Worksheets("Scrap") .Hyperlinks.Add Anchor:=.Range("C3"), _ Address:="X:\PERI skrot 2015\Peri skrot i ugere\" & Dato1 & "\" End With Sheets("Scrap").Range("D3").Value = strbruger Sheets("Scrap").Range("E3").Value = Dato If Kundescrott = True Then Sheets("Scrap").Range("F3").Value = "Kunde Scrott" Else Sheets("Scrap").Range("F3").Value = "Peri Scrott" End If Sheets("Scrap").Select Range("H3").Select Sheets("Scrap").Select Range("I3").Select ActiveCell.FormulaR1C1 = "=LEFT(RC[-8],6)" ' ActiveCell.FormulaR1C1 = "=IF(R[]C[-1]="""","""",TODAY())" ' Denne er kun aktuel, hvis datoen ikke ændres sig når dokumentet åbnes Range("J3").Select ' Denne og nedestående linje skal ændres, når jeg ved hvor Dejan ligger excel dokumentet 'ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'C:\Users\vibov\Desktop\[Copy of 0243 article price list.xls]price list, Product Group'!R1C4:R65536C20,17,FALSE)" ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],'G:\Martin Vibov\Projekter\Scrap\[Copy of 0243 article price list.xls]price list, Product Group'!R1C4:R10000C20,4,FALSE)" Range("K3").Select ActiveCell.FormulaR1C1 = "=SUM(RC[-1]*RC[-9])" Rows("3:3").Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Else: End If Sheets("Dropdown").Select Unload Me Dato = "" Dato1 = "" 'Application.ScreenUpdating = False End Sub |
#4
|
||||
|
||||
Perhaps you could offer a clue as to how and where you have declared your variables and which is the reference to your combobox?
|
#5
|
|||
|
|||
Sorry
Sorry for not shared all, but i had some issue regarding add some Picture.
when i have put something together that make sence, then i will come back to you. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create UserForm ComboBox or ContentControl | ptmuldoon | Word VBA | 11 | 01-17-2015 05:58 PM |
VBA Code in a UserForm module to delete a Command Button which opens the userform | Simoninparis | Word VBA | 2 | 09-21-2014 03:50 AM |
Is it possible to take an input from a UserForm in one document to a UserForm in a do | BoringDavid | Word VBA | 5 | 05-09-2014 09:08 AM |
ComboBox ListIndex = -1 even though it does NOT = -1 | Joe Patrick | Word VBA | 0 | 08-03-2011 08:34 AM |