How do i explain..
I'm running a macro from a sheet to show a form. This form is the basis to put data into that particular sheet. Now when i run the macro the initiliaze from the form is running. I did solved the problem thx to people on this forum to change the caption of the chechbox when the standaard database is filled or not filled. Therefore i go in the initilize to the sheet standaard but afterwards i need to return to the last active sheet. I found a way but i'm not that happy with it. The initiliaze doesn't show the sheet where to put data in.
For example
Standaard = database
Home = navigation sheet to go to other sheets when date is filled
Sheet 1 = 1ste of the month
Macro is run from sheet1 --> initialize --> show form --> possibility to put in data
Now the form shows up but the background is still the home page and i need the active sheet in this example sheet 1 (if date is different then this sheet needs to change also)
--> initilize calls for sub..Code:Private Sub UserForm_Initialize() MultiPage1.Value = 0 ActiveSheet.Range("d2").Select Label10.Caption = ActiveSheet.Range("d2") Call algemeen Chk1 = False ....
--> Application.run ("datum") is the macro to go from the homepage to the sheet according to the date. I tried with a pauze macro but it isn't helping..In this example sheet 1 needs to be displayed in the back of the screen.Code:Private Sub algemeen() Dim std As Worksheet Dim TempName As String Set std = Worksheets("standaard") std.Visible = xlSheetVisible std.Select Range("B8:B19").Select ActiveCell.Offset(0, 0).Select For I = 1 To 12 TempName = "chk" & I If ActiveCell <> "" Then ActiveCell.Offset(0, 16).Select Me.Controls(TempName).Caption = ActiveCell.Value Me.Controls(TempName).Enabled = True ActiveCell.Offset(1, -16).Select Else Me.Controls(TempName).Caption = "" Me.Controls(TempName).Enabled = False ActiveCell.Offset(1, 0).Select End If Next std.Visible = xlSheetVeryHidden 1 Worksheets("HOME").Select 2 ActiveCell.Offset(0, 2).Select 3 Application.Run ("Datum") 4 Pause (2) End Sub
--> This macro i also need in a seperate way to navigate to the daily database sheets.Code:Sub Datum() ' ' Ga naar de desbetreffende dag van de maand ' Dim I As Integer Sheets("HOME").Select Application.ScreenUpdating = False Selection.Offset(0, -2).Select If ActiveCell.Text = "" Then MsgBox ("Je moet op de datum gaan staan") Range("a1").Select Else Dim a As Variant a = ActiveCell.Text Sheets(a).Visible = True Sheets(a).Select ActiveSheet.Unprotect Range("D2:K2").Select Selection.Copy Range("S6").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Range("D1").Select Application.CutCopyMode = False Selection.Copy Range("S5").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Range("S4").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "=IF(R[1]C>R[2]C+0.25,""OK"",""NIET OK"")" Range("S4:S6").Select Range("S6").Activate Selection.Font.ColorIndex = 2 Range("a1").Select ActiveSheet.Protect ActiveWindow.SmallScroll Down:=-150 End If End Sub
Question --> i want to initiliaze (this for the caption of the checkboxes) but then return to the form with the wright background.


Reply With Quote
