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

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

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন