শুক্রবার, ১৫ জুলাই, ২০১৬

modviewdata

Option Explicit

Sub ViewLogFirst()
 
    Dim historyWks As Worksheet
    Dim inputWks As Worksheet
    Dim rngA As Range

    Dim lRec As Long
    Dim lRecRow As Long
    Dim lLastRec As Long
    Dim lastRow As Long
    Application.EnableEvents = False
   
    Set inputWks = Worksheets("Input")
    Set historyWks = Worksheets("MasterData")
    Set rngA = ActiveCell

    With historyWks
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row - 1
        lLastRec = lastRow - 1
    End With

    With inputWks
        .Range("CurrRec").Value = 1
        lRec = .Range("CurrRec").Value
        lRecRow = lRec + 1
        historyWks.Range(historyWks.Cells(lRecRow, 3), historyWks.Cells(lRecRow, 11)).Copy
        .Range("D5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
        inputWks.Range("OrderSel").Value = .Range("D5").Value
        rngA.Select
    End With
    Application.EnableEvents = True

End Sub
Sub ViewLogUp()
 
    Dim historyWks As Worksheet
    Dim inputWks As Worksheet
    Dim rngA As Range

    Dim lRec As Long
    Dim lRecRow As Long
    Dim lLastRec As Long
    Dim lastRow As Long
    Application.EnableEvents = False
   
    Set inputWks = Worksheets("Input")
    Set historyWks = Worksheets("MasterData")
    Set rngA = ActiveCell

    With historyWks
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row - 1
        lLastRec = lastRow - 1
    End With

    With inputWks
        lRec = .Range("CurrRec").Value
        If lRec > 1 Then
            .Range("CurrRec").Value = lRec - 1
            lRec = .Range("CurrRec").Value
            lRecRow = lRec + 1
        historyWks.Range(historyWks.Cells(lRecRow, 3), historyWks.Cells(lRecRow, 11)).Copy
        .Range("D5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
        inputWks.Range("OrderSel").Value = .Range("D5").Value
        rngA.Select
          End If
    End With
    Application.EnableEvents = True

End Sub

Sub ViewLogDown()

    Dim historyWks As Worksheet
    Dim inputWks As Worksheet
    Dim rngA As Range

    Dim lRec As Long
    Dim lRecRow As Long
    Dim lLastRec As Long
    Dim lastRow As Long
    Application.EnableEvents = False
   
    Set inputWks = Worksheets("Input")
    Set historyWks = Worksheets("MasterData")
    Set rngA = ActiveCell

    With historyWks
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row - 1
        lLastRec = lastRow - 1
    End With

    With inputWks
        lRec = .Range("CurrRec").Value
        If lRec < lLastRec Then
            .Range("CurrRec").Value = lRec + 1
            lRec = .Range("CurrRec").Value
            lRecRow = lRec + 1
        historyWks.Range(historyWks.Cells(lRecRow, 3), historyWks.Cells(lRecRow, 11)).Copy
        .Range("D5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
        inputWks.Range("OrderSel").Value = .Range("D5").Value
        rngA.Select
          End If
    End With
    Application.EnableEvents = True

End Sub

Sub ViewLogLast()
 
    Dim historyWks As Worksheet
    Dim inputWks As Worksheet
    Dim rngA As Range

    Dim lRec As Long
    Dim lRecRow As Long
    Dim lLastRec As Long
    Dim lastRow As Long
    Application.EnableEvents = False
   
    Set inputWks = Worksheets("Input")
    Set historyWks = Worksheets("MasterData")
    Set rngA = ActiveCell

    With historyWks
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row - 1
        lLastRec = lastRow - 1
    End With

    With inputWks
        .Range("CurrRec").Value = lLastRec
        lRec = .Range("CurrRec").Value
        lRecRow = lRec + 1
        historyWks.Range(historyWks.Cells(lRecRow, 3), historyWks.Cells(lRecRow, 11)).Copy
        .Range("D5").PasteSpecial Paste:=xlPasteValues, Transpose:=True
        inputWks.Range("OrderSel").Value = .Range("D5").Value
        rngA.Select
    End With
   
    Application.EnableEvents = True

End Sub

শুক্রবার, ২৪ জুন, ২০১৬

Login - hide

Private Sub CommandButton2_Click()
 If TextBox1 = "robi" Then
 MsgBox "welcome"
 Application.Visible = True
 Unload Me
 Unload UserForm1
 Else
    MsgBox "Wrong Password"
 End If
 
 
End Sub
Private Sub CommandButton1_Click()
Unload Me
ActiveWorkbook.Close True
Application.Quit

End Sub
Private Sub Workbook_Open()
Application.Visible = False
UserForm1.Show

End Sub

শুক্রবার, ৩ জুন, ২০১৬

Login Form code

private....
dim username, password as string

username = textbox1.text
password = textbox2.text

if username = "myuser" and password = "mypassword" then
   msgbox "You entered the correct info", vbInformation
    Unload Me 'unload this form
else
     msgbox "You entered the wrong info", vbcritical
    'now close the workbook
    ActiveWorkbook.close
    
End if
End sub


--------------

private...
    'show the form when the workbook is open
    UserForm1.show
End sub