Loop through the cell and give the anser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snanjund
    New Member
    • Sep 2016
    • 4

    Loop through the cell and give the anser

    PLEASE HELP ME ON BELOW QUERY
    I HAVE 5 COLUMNS...
    I HAVE SORTED THE DATA FROM SMALLEST TO HIGHEST(code column)...
    NOW I WANT TO COMPARE SUBCATEGORY WHETHER 1ST AND 2 ROW DATA IS ARE SAME, IF YES THEN I SHOULD GET RESULT AS TRUE
    FOR EXAMPLE GIVEN BELOW
    CODE--NAME--DATE--CATEGORY--SUBCATEGORY--RESULT
    1------A----2015---HC---------HCP1--------TRUE
    1------AA---2016---HC---------HCP1--------FALSE
    1------AC---2016---PC---------RED1--------FALSE
    4------D----2016---OC---------RED2--------FALSE
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    snanjund,

    What have you tried to do?

    --Oralloy

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      An Excel Formula approach does not immediately come to mind, but the following Macro will work assuming the Worksheet is named Sheet1 and the SUBCATEGORY Values start in Row# 2/Column# 5:
      Code:
      Dim sht As Excel.Worksheet
      Dim intRow As Integer
      
      Set sht = ActiveWorkbook.Worksheets("Sheet1")
      
      intRow = 2
      
      With sht
        Do While .Cells(intRow, "E") <> ""
          'Assuming Categories start in Row# 2/Column# 5
          If .Cells(intRow, "E").Value = .Cells(intRow + 1, "E") Then
            .Cells(intRow, "F") = "TRUE"
          Else
            .Cells(intRow, "F") = "FALSE"
          End If
            intRow = intRow + 1
        Loop
      End With

      Comment

      • snanjund
        New Member
        • Sep 2016
        • 4

        #4
        HI ADezii,

        Many thanks for your response..

        can we do same in MS access database, as i have around 2+ lakhs data line items.. and i am also performing few calculation in access database, so that this will help me if i loop of cells in Access database.

        waiting for your feedback :)

        Comment

        • snanjund
          New Member
          • Sep 2016
          • 4

          #5
          HI Orally,

          i want to perform this in MS access database..

          could you help help how can i resolve this.

          waiting for you feedback many thanks

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Need a little more of an explanation than that which you have provided.

            Comment

            • snanjund
              New Member
              • Sep 2016
              • 4

              #7
              HI Adezii,

              is there any possible way that i can fix this using ACCESS DATA BASE instead of excel VBA...

              i have data around 2lakhs rows if i perform this operation in excel using VBA it takes time. so i want to fix this requirement in access data base.

              Comment

              Working...