Excel උදව්වක් ඕන (VBA හරි කමක්නෑ)

TakaTakas

Well-known member
  • Nov 20, 2014
    2,865
    1,007
    113
    ගෙදර
    p37U1iW.jpg


    මෙහෙම එන්නෙ ඇයි මචං. මට දැන් කවුරු හරි මේල් එකක් එවල තිබුනා Excel ෆයිල් එක හදල ගන්න බයයි
     

    imhotep

    Well-known member
  • Mar 29, 2017
    14,861
    8
    35,448
    113
    If you want to press a button to do this then you have to enable the Developer mode, insert a Button Form control and assign a VBA macro code to do the job.
     
    • Like
    Reactions: TakaTakas

    TakaTakas

    Well-known member
  • Nov 20, 2014
    2,865
    1,007
    113
    ගෙදර
    මචං මට මේ කෝඩ් එකේ කොලම් 1 සහ 2 වෙනස් කරල
    මට ඕන රෝ එකක් දාගන්න යි. මුළු කොලම් එකම සෙලකේට් වෙන්නෙ නැතිව
    මට අවශ්‍ය සෙල් රේන්ජ් එකයි දාගන්න විදිය කියපන්කො තරහ නැතිව.

    Private Sub CommandButton1_Click()
    Dim RangeToFormat As Range
    Dim RangeToFormat1 As Range
    Set RangeToFormat = ThisWorkbook.ActiveSheet.Columns(1)
    Set RangeToFormat1 = ThisWorkbook.ActiveSheet.Columns(2)

    Call ApplyCondition(RangeToFormat, "=B1")
    Call ApplyCondition(RangeToFormat1, "=A1")
    End Sub
    Private Sub ApplyCondition(RangeToFormat As Range, Condition As String)
    RangeToFormat.FormatConditions.Delete

    RangeToFormat.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
    Formula1:=Condition
    RangeToFormat.FormatConditions(RangeToFormat.FormatConditions.Count).SetFirstPriority
    With RangeToFormat.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = 255
    .TintAndShade = 0
    End With
    RangeToFormat.FormatConditions(1).StopIfTrue = False
    End Sub


    8XgWJeV.jpg
     

    rmpuom

    Well-known member
  • Jun 10, 2008
    880
    302
    63
    hHrvNmo.jpg


    මේ වගේ කොලම් දෙකක තියන නම්බර්ස් වගයක් තියනවා.මේකෙ පාට කරල තියනවා වගේ සමාන අංක තියන සෙල් පාට වෙන්න ඕන.හැබැයි Row බයි Row වෙන්න ඕන.උදා හරණයක් විදියට A2 සෙල් එක සමානද කියල බලන්න ඕන B2 සෙල් එකත් එක්ක විතරයි.අනිත් මොන සෙල් එක A2 ට සමාන උනත් වැඩක් නෑ.ඒ විදියට මේ පිංතූරෙ තියනවා වගේ 2 වෙනි Row එකේ A2 = B2 ඒක නිසා ඒසෙල් දෙක පාට උනා.A3 සෙල් එක B3 ට සමාන නෑ.ඒක නිසා ඒවා පාට උනේ නෑ.හැබැයි A3 = B8 , එහෙම උනාට ඒ සෙල් පාට වෙලා නෑ.(ඒ කියන්නෙ මම දන්න තරමින් conditional formatting පාවිච්චි කරන්න බෑ ) මේ වැඩේ කරගන්න පුළුවන් VBA කෝඩ් එකක් හරි වෙන මෙතඩ් එකක් හරි දන්න කෙනෙක් කියල දෙන්න පුළුවන්ද ?


    ochchara natanna one na ban thawa column ekak add karaganin C kiyala itapasse C1=A1-B1 widiyata liyapan.. itapasse A column ekatai B column ekatayi conditionel format ekak liyapan C value eka =0 nam colour wenna... saralai..
     

    imhotep

    Well-known member
  • Mar 29, 2017
    14,861
    8
    35,448
    113
    Just define another variable to get the last row into the code...
    eg
    'Get the last row
    lastRow = Sheet1.Range("A1").CurrentRegion.Rows.Count