I have the following issue:
I create a userform in excel 2013 and add for starters one text box to show the date and right underneath a combobox which is reflecting a data validation list.
As soon as i write the code
Private Sub UserForm_Initialize()
Me.tbDate = Date
'fill combobox
For Each cell In [cartridges]
Me.cmbCartridges.AddItem cell
Next cell
End Sub
Can anyone help pretty please?
Thanks in advance
The code should work. I am running Excel 2013 as well and just tested your code with no problems.
Two things to check.
1
Make sure that the defined name is spelled exactly the same way in the VBA code as it is in the Name Manger.
2
Make sure that the defined name does not evaluate to an error.
Related
I have attempted the solution previously posted
https://stackoverflow.com/a/31642837/6463950
but whilst this code works nicely it doesn't get round the issue of wanting to have the database hidden from the user view. Has anyone determined a way to do this?
I am using the following code. If I hide the worksheet or hide the columns on TimeCapture then I get a runtime error '1004'
Sub OrderEntry()
Sheets("TimeCapture").Select
Range("a1").CurrentRegion.Name = "database"
ActiveSheet.ShowDataForm
End Sub
There is no need to select or active the sheet. You can even have the worksheet hidden.
Use:
Sheets("TimeCapture").ShowDataForm
I want to set the following formula(its already working fine) in first 1000 rows in excel.Actually I am looking in VBA. But, I am not familiar in VBA code.
=IFERROR(VLOOKUP(DD,HDR_COLMN,COLUMN(),0),"")
DD - getting data from another sheet
HDR_COLMN - getting table header from another sheet(Sheet2) and showing as drop down values in Sheet1
Please any one can help me. Advance thanks
The only tricky part is the double-quotes.
Say we want to deposit this with VBA
=IFERROR(VLOOKUP(A1,B1:C10,2,TRUE),"")
This will do it:
Sub luxation()
Range("A10").Formula = "=IFERROR(VLOOKUP(A1,B1:C10,2,TRUE),"""")"
End Sub
I'm very new to VBA and i searched and searched on Google, but can't find an example which deals with my problem.
I got a list of names which I want to put inside a selectable dropdownlist. When i click their name I want to run a different macro i made with their name on.
I tried a lot of things yesterday, but everytime it only succed me to assign 1 macro which was called no matter which name i pressed.
I think the solution is pretty simple, but i really got no clue how to do this the most simple way. So hopefully any of you got a link to a simple tutorial or can explain it to me in steps.
Thanks in advance
EDIT:
I got 2 names.
Birgitte = A:1
Thomas = A:2
I got a form comboxbox where both names are in.
When i press Birgitte i want a macro called BS_Opgave() to run and when i pres Thomas i want Macro TR_Opgave to run.
My problem is I'm not sure how to connect the combox selection to a Macro in the VBA editor. I'm acutyally confused about everything in the editor about comboxing.
Paste this code in a module. The Right Click on the Combobox and assign the macro DropDown1_Change to it :) And you are done.
Option Explicit
Sub DropDown1_Change()
With ThisWorkbook.Sheets("Sheet1").Shapes("Drop Down 1").ControlFormat
Select Case .List(.Value)
Case "Birgitte": BS_Opgave
Case "Thomas": TR_Opgave
End Select
End With
End Sub
Sub BS_Opgave()
MsgBox "You selected Birgitte"
End Sub
Sub TR_Opgave()
MsgBox "You selected Thomas"
End Sub
ASSUMPTIONS
I am assuming the following
The name of the combobox is "Drop Down 1"
The combobox is in "Sheet1"
I have the following VBA code, which should show a dataform from another hidden sheet.
Sub CoverageBssEntry()
Application.ScreenUpdating = False
Sheets("myhiddensheet").Select
Range("myTable[#All]").Select
ActiveSheet.ShowDataForm
End Sub
When I run this, the data form does not containt the labels and inputboxes of this table.
Any help is really appreciated, because it is driving me nuts! My only other option is to spend time to build custom made user forms, while this would do perfectly.
You cannot select a hidden sheet. And anyway the .Select statements are not necessary
Try
Sheets("myhiddensheet").ShowDataForm
The fix is to use:
ActiveSheet.Cells(x,y).Select
prior calling the .ShowDataForm, works like a jiffy!
I think there are genuine constraints with the ShowDataForm command. It works fine if invoked outside of VBA while in a specific range. But once coded into VBA, it will only return the form for the first table in the referenced worksheet, even if a macro was recorded to perform that action.
I cannot tell why. Maybe because the showdataform event is tied to the worksheet and not to the table or list selected when it is called. Sorry guys. Maybe microsoft will improve this in the future.
I have multiple shapes and checkboxes in a spreadsheet. I want to create a function that places a particular shape to front (a higher Z-order than its peers) when its corresponding checkbox is clicked. This is the code that I currently have:
Sub CheckBox3_Click()
If CheckBox3.Value = True Then
Sheet1.Shapes("blueoval").ZOrder msoBringToFront
End If
End Sub
I get Run-time Error '424' whenever I run this code. I am new to VBA for excel, so any help would be greatly appreciated. What's wrong with this code? What's missing? etc.. Thanks!
Your code works for me.
Check that:
Your checkbox is an ActiveX control and not a Form control.
The checkbox name is CheckBox3.
You have a shape on Sheet1 called blueoval.
The sheet name with the blue oval is actually Sheet1 (check this in the Visual Basic Editor).
In the Visual Basic Editor, select Tools > References and make sure there are no references marked MISSING.
Your code is on the worksheet where the checkbox is and not in a separate module.