Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Avinash Crap Pending sorting out

  1. #1
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0

    Avinash Crap Pending sorting out

    Moderator Notice:
    In the course of sorting the mess out typically said OP posts, I may need to temporarily to store stuff here. Most stuff here does not really fit anywhere, but I might need bits of it in thee future when straitening out the mess he makes..

    I have this Macro & i am modifying the same as per my needs

    Code:
    Sub STEP6()
    Dim Wbm As Workbook: Set Wbm = ThisWorkbook
    Dim Wb1 As Workbook, Wb2 As Workbook
    Dim strWb1 As String: Let strWb1 = "1.xls"
    Dim strWb2 As String: Let strWb2 = "Error.xlsx"
    
    Dim Ws1 As Worksheet, Ws2 As Worksheet
    Dim Lr1 As Long, Lr2 As Long: Let Lr1 = 5000: Lr2 = 5000
    
     Workbooks.Open FileName:=ThisWorkbook.Path & "\" & strWb2
     Set Wb2 = ActiveWorkbook '
     Set Ws2 = Wb2.Worksheets.Item(1)
     Workbooks.Open FileName:=ThisWorkbook.Path & "\" & strWb1
     Set Wb1 = ActiveWorkbook
     Set Ws1 = Wb1.Worksheets.Item(1)
    
    Dim rngSrch As Range: Set rngSrch = Ws2.Range("C1:C" & Lr2 & "")
    Dim rngDta As Range: Set rngDta = Ws1.Range("B2:B" & Lr1 & "")
    
    Dim Cnt As Long
        For Cnt = Lr2 To 1 Step -1
        Dim MtchedCel As Variant
         Set MtchedCel = rngSrch.Find(what:=rngDta.Item(Cnt), After:=rngSrch.Item(1), LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext, MatchCase:=True)
            If Not MtchedCel Is Nothing Then
             rngDta.Rows(Cnt).EntireRow.Delete Shift:=xlUp
            Else
            End If
            
        Next Cnt
     Wb1.Close SaveChanges:=True
     Wb2.Close SaveChanges:=True
    End Sub

    changed Macro
    Code:
    Sub STEP6()
    Dim Wbm As Workbook: Set Wbm = ThisWorkbook
    Dim Wb1 As Workbook, Wb2 As Workbook
                                                                                                                           'Dim strWb1 As String: Let strWb1 = "1.xls"
                                                                                                                            'Dim strWb2 As String: Let strWb2 = "Error.xlsx"
    
    Dim Ws1 As Worksheet, Ws2 As Worksheet
                                                                                                                   'Dim Lr1 As Long, Lr2 As Long: Let Lr1 = 5000: Lr2 = 5000(I have to remove the limitation of the macro plz see this line and plz let me know the changes for this also)
    
                                                                                                                       'Workbooks.Open FileName:=ThisWorkbook.Path & "\" & strWb2
     Set Wb2 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\Error.xlsx")              'ActiveWorkbook 
     Set Ws2 = Wb2.Worksheets.Item(1)
                                                                                                                         'Workbooks.Open FileName:=ThisWorkbook.Path & "\" & strWb1
     Set Wb1 = Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xls")                                                                                                  ' ActiveWorkbook
     Set Ws1 = Wb1.Worksheets.Item(1)
    
    Dim rngSrch As Range: Set rngSrch = Ws2.Range("C1:C" & Lr2 & "")
    Dim rngDta As Range: Set rngDta = Ws1.Range("B2:B" & Lr1 & "")
    
    Dim Cnt As Long
        For Cnt = Lr2 To 1 Step -1
        Dim MtchedCel As Variant
         Set MtchedCel = rngSrch.Find(what:=rngDta.Item(Cnt), After:=rngSrch.Item(1), LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlNext, MatchCase:=True)
            If Not MtchedCel Is Nothing Then
             rngDta.Rows(Cnt).EntireRow.Delete Shift:=xlUp
            Else
            End If
            
        Next Cnt
     Wb1.Close SaveChanges:=True
     Wb2.Close SaveChanges:=True
    End Sub


    Plz see the changes that i made as per my needs
    & I have to remove this line & wanted to remove the limitation of this macro
    Code:
    Dim Lr1 As Long, Lr2 As Long: Let Lr1 = 5000: Lr2 = 5000
    plz suggest instead of this what i have to use & u already shared similar solution but i need cnfirmation from u so plz see and let me know again sir
    Last edited by DocAElstein; 07-26-2020 at 04:37 PM. Reason: Avinash Crap Pending sorting out

  2. #2
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0

    Avinash Crap Pending sorting out

    Moderator Notice:
    In the course of sorting the mess out typically said OP posts, I may need to temporarily to store stuff here. Most stuff here does not really fit anywhere, but I might need bits of it in thee future when straitening out the mess he makes..







    Code:
    Sub STEP10()
    
    Dim oWB As Workbook
    Dim oSheet As Worksheet
    Dim FSO As Object, MyFile As Object
    Dim FileName As String
    Dim Arr As Variant, vRow As Variant
    Dim NextRow As Long, lngRow As Long, lngCol As Long
        Set oWB = Workbooks.Open(ThisWorkbook.Path & "\Error.xlsx")
        Set oSheet = oWB.Sheets(1)
        NextRow = oSheet.UsedRange.Rows(oSheet.UsedRange.Rows.Count).Row + 1
        FileName = oWB.Path & "\BasketOrder..csv"
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Set MyFile = FSO.OpenTextFile(FileName, 1)
        Arr = Split(MyFile.ReadAll, vbNewLine)
        For lngRow = 0 To UBound(Arr)
            vRow = Split(Arr(lngRow), ",")
            For lngCol = 0 To UBound(vRow)
                oSheet.Cells(NextRow, lngCol + 1) = vRow(lngCol)
            Next lngCol
            NextRow = NextRow + 1
        Next lngRow
        oWB.Save
        Set FSO = Nothing
        Set oSheet = Nothing
        Set MyFile = Nothing
        oWB.Close SaveChanges:=True
    End Sub


    Code:
    Sub STEP3()
        Dim wb1 As Workbook
        Dim wb2 As Workbook
        Dim wb3 As Workbook
        Dim ws1 As Worksheet
        Dim ws2 As Worksheet
        Dim ws3 As Worksheet
        Dim strPath As String
        Dim R As Long
        Dim m As Long
        Dim rng As Range
        Dim n As Long
        Application.ScreenUpdating = False
        Set wb1 = Workbooks.Open(ThisWorkbook.Path & "\1.xls")
        Set ws1 = wb1.Worksheets(1)
        m = ws1.Range("H" & ws1.Rows.Count).End(xlUp).Row
        strPath = ThisWorkbook.Path & "\"
        Set wb2 = Workbooks.Open(strPath & "OrderFormat.xlsx")
        Set ws2 = wb2.Worksheets(1)
        ws2.Range("A1:A4").TextToColumns DataType:=xlDelimited, Tab:=True, _
        SemiColon:=False, Comma:=False, Space:=False, Other:=False, _
        ConsecutiveDelimiter:=False
        Set wb3 = Workbooks.Open(strPath & "BasketOrder..csv")
        Set ws3 = wb3.Worksheets(1)
        Set rng = ws3.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
        If rng Is Nothing Then
            n = 1
        Else
            n = rng.Row + 1
        End If
        For R = 2 To m
            If ws1.Range("H" & R).Value > ws1.Range("D" & R).Value Then
                ws2.Range("A2").EntireRow.Copy Destination:=ws3.Range("A" & n)
                n = n + 1
            ElseIf ws1.Range("H" & R).Value < ws1.Range("D" & R).Value Then
                ws2.Range("A4").EntireRow.Copy Destination:=ws3.Range("A" & n)
                n = n + 1
            End If
        Next R
        Application.DisplayAlerts = False
        wb1.Close SaveChanges:=False
        wb2.Close SaveChanges:=False
        wb3.SaveAs Filename:=strPath & "BasketOrder..csv", FileFormat:=xlCSV
        wb3.Close SaveChanges:=False
        Application.DisplayAlerts = True
        Application.ScreenUpdating = True
    End Sub

    I have these code it works perfect
    But i changed BasketOrder..csv to BasketOrder.xlsx
    so in this macro changes are required for the same
    Last edited by DocAElstein; 07-26-2020 at 04:25 PM.

  3. #3
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0

    Macro Correction

    Code:
    Sub STEP11()
     
       Dim wbk1 As Workbook
       Dim wsh1 As Worksheet
     
       Application.ScreenUpdating = False
     
       Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\BasketOrder..csv")
       Set wsh1 = wbk1.Worksheets(1)
     
       With wsh1
       On Error Resume Next
       wsh1.Columns("C").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
       
    End With
    
    
       Application.DisplayAlerts = False
       wbk1.Close SaveChanges:=True
       Application.DisplayAlerts = True
     
       Application.ScreenUpdating = True
     
    End Sub



    Code:
    Sub STEP12()
     
       Dim wbk1 As Workbook
       Dim wsh1 As Worksheet
     
       Application.ScreenUpdating = False
     
       Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\Error.xlsx")
       Set wsh1 = wbk1.Worksheets(1)
     
       With wsh1
       On Error Resume Next
       wsh1.Columns("C").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
       
    End With
    
    
       Application.DisplayAlerts = False
       wbk1.Close SaveChanges:=True
       Application.DisplayAlerts = True
     
       Application.ScreenUpdating = True
     
    End Sub
    These code works perfect
    But as per recommendation this macro has on error resume next ,so i wanted to remove on error resume next in the macro & wanted to make it perfect

  4. #4
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    Last edited by DocAElstein; 09-22-2023 at 05:17 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  5. #5
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    Where does the original macro come from
    What is it supposed to do
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  6. #6
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,446
    Rep Power
    10
    Where does the original macro come from.
    What is it supposed to do.


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=QdwDnUz96W0&lc=Ugx3syV3Bw6bxddVyBx4AaABAg
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg.9fxrOrrvTln9g9wr8mv2 CS
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g7lhoX-ar5
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh
    https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg.9g9wJCunNRa9gJGhDZ4R I2
    https://www.youtube.com/watch?v=Sh1kZD7EVj0&lc=Ugz-pow-E8FDG8gFZ4l4AaABAg.9f8Bng22e5d9f8hoJGZY-5
    https://www.youtube.com/watch?v=Sh1kZD7EVj0&lc=Ugxev2gQt7BKZ0WYMfh4AaABAg.9f6hAjkC0ct9f8jleOui-u
    https://www.youtube.com/watch?v=Sh1kZD7EVj0&lc=Ugxg9iT7MPWGBWruIzR4AaABAg
    https://www.youtube.com/watch?v=tzbKqTRuRzU&lc=UgyYW2WZ2DvSrzUKnJ14AaABAg
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=jTmVtPHtiTg&lc=Ugy_RiNN_kAqUvZ8W994AaABAg
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNsaS3Lp1
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgR1EPUkhw
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNe_XC-jK
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgNPOdiDuv
    https://www.youtube.com/watch?v=QjEWAJ3d-jw&lc=UgxJLVpwY8fIla7G-pN4AaABAg.9BLeCWVhxdG9wgN7AC7wAc
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg
    https://www.youtube.com/watch?v=DVFFApHzYVk&lc=Ugyi578yhj9zShmhuPl4AaABAg
    https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgxvxlnuTRWiV6MUZB14AaABAg
    https://www.youtube.com/watch?v=_8i1fVEi5WY&lc=Ugz0ptwE5J-2CpX4Lzh4AaABAg
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxoHAw8RwR7VmyVBUt4AaABAg.9C-br0lEl8V9xI0_6pCaR9
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=Ugz5DDCMqmHLeEjUU8t4AaABAg.9bl7m03Onql9xI-ar3Z0ME
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgxYnpd9leriPmc8rPd4AaABAg.9gdrYDocLIm9xI-2ZpVF-q
    https://www.youtube.com/watch?v=0ltJS7uHfK4&lc=UgyjoPLjNeIAOMVH_u94AaABAg.9id_Q3FO8Lp9xHyeYSuv 1I
    https://www.reddit.com/r/windowsxp/comments/pexq9q/comment/k81ybvj/?utm_source=reddit&utm_medium=web2x&context=3
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgxYgiEZuS9I3xkjJv54AaABAg
    https://www.youtube.com/watch?v=bs-urI_o8jo&lc=UgyBACXgNY4j_cHgH5J4AaABAg.9oTkVdzfqfm9wlhQrYJP 3M
    ttps://www.youtube.com/watch?v=LP9fz2DCMBE
    https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg
    https://www.youtube.com/watch?v=LP9fz2DCMBE&lc=UgzbPgJUMCztIOQDym14AaABAg.9wdo_rWgxSH9wdpcYqrv p8
    ttps://www.youtube.com/watch?v=bFxnXH4-L1A
    https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxuODisjo6cvom7O-B4AaABAg.9w_AeS3JiK09wdi2XviwLG
    https://www.youtube.com/watch?v=bFxnXH4-L1A&lc=UgxBU39bTptFznDC1PJ4AaABAg
    ttps://www.youtube.com/watch?v=GqzeFYWjTxI
    https://www.youtube.com/watch?v=GqzeFYWjTxI&lc=UgwJnJDJ5JT8hFvibt14AaABAg
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 11-30-2023 at 03:06 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

  7. #7
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    I got this macro in 2019 & I have not remebered from which forum i got this macro
    I am sending the sample file plz give me some time

  8. #8
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    I got this macro in 2019 & I have not remebered from which forum i got this macro
    I am sending the sample file plz give me some time

  9. #9
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    I am sending the sample file plz give me some time

  10. #10
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0

    Avinash Crap Pending sorting out

    Code:
    Sub STEP7()
        Dim Wb1 As Workbook
        Dim wb3 As Workbook
        Dim Ws1 As Worksheet
        Dim ws3 As Worksheet
        Dim strPath As String
        Dim r As Long
        Dim m As Long
        Dim rng As Range
        Dim n As Long
        Application.ScreenUpdating = False
        Set Wb1 = Workbooks.Open(ThisWorkbook.Path & "\1.xls")
        Set Ws1 = Wb1.Worksheets(1)
        m = Ws1.Range("B" & Ws1.Rows.Count).End(xlUp).Row
        strPath = ThisWorkbook.Path & "\"
        Set wb3 = Workbooks.Open(strPath & "BasketOrder..csv")
        Set ws3 = wb3.Worksheets(1)
        Set rng = ws3.Range("C:C").Find(what:="*", searchorder:=xlByRows, SearchDirection:=xlPrevious)
        If rng Is Nothing Then
            n = 1
        Else
            n = rng.Row + 1
        End If
        For r = 2 To m
            ws3.Range("C" & n).Value = Ws1.Range("B" & r).Value
            n = n + 1
        Next r
        Application.DisplayAlerts = False
        wb3.SaveAs FileName:=strPath & "BasketOrder..csv", FileFormat:=xlCSV
        wb3.Close SaveChanges:=False
        Wb1.Close SaveChanges:=False
        Application.DisplayAlerts = True
        Application.ScreenUpdating = True
    End Sub

    I have this macro which is working perfect but i converted the basketorder..csv to basketorder.xlsx so i need the modification according to that
    plz see the sample file
    condition: Copy column B data of 1.xls and paste it to column C of basketorder.xlsx(exclude the header of column B of 1.xls and simply paste the rest data to column C of basketorder.xlsx )
    Attached Files Attached Files

Similar Threads

  1. Replies: 14
    Last Post: 07-26-2020, 01:55 PM
  2. Excel Sheet Correction
    By johnny03 in forum Excel Help
    Replies: 1
    Last Post: 12-19-2014, 07:27 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •