Function ObjRef(ObjName as String) as ObjectI have several labels on a form that I would like to be able to iterate through in a loop. They are named, for example, Label1, Label2, etc. If I could refer to the objects by name, then I could do something like:
Dim i as long For i = 1 to ObjCount If ObjRef("Label"&i).Value > 0 Then ' do something here based on that value End If Next iCurrently my workaround is to have an array of Object, and initialize it by setting each element to one of the labels, then working with the array. Would be nice to address the labels directly.
dim ctrl as control For i = 1 To 7 Rcontrolname = "ac_al_" & i ctrl = Me.Controls(Rcontrolname) Set RACs(i).RACGroup = ctrl) Next i
Private Sub CheckBox102_Click() 'Gives Object number (checkbox102 = 102) Dim N As String Dim O As String Dim Num As String O = Me.ActiveControl.Name N = Right(O, Len(O) - 5) N = Left(N, Len(N) - 2) If Len(N) = 3 Then Num = Right(N, Len(N) - 2) Else Num = Right(N, Len(N) - 3) End If msgbox Num End subI would like the line that says Me.Activecontrol.Name to refer to the Object Checkbox102 itself. The reason I need this is because i have the checkbox within a frame and when that "me.activecontrol.name" comes around it refers to Frame1.
Sub Button17_Click() Sheets("Blank 1").Activate Range("E6").Select End Sub...to assign to a button to change sheets (obviously...). The trouble is that the sheets in the workbook change name, via another macro. So the sheet known as 'Blank 1', when filled in, might be called something else entirely.
VB: Public Sub GetEmbeddedCharts() Dim myChart As ChartObject Dim myCharts As ChartObjects Set myCharts = ActiveSheet.ChartObjects For Each myChart In myCharts Debug.Print myChart.Chart.Name Next End Sub If you like these VB formatting tags please consider sponsoring the author in support of injured Royal MarinesThanks,