Hi All,
I wrote the code with 1000+ line , but when i add some lines and run its getting Procedure is too large. so i want to create another macro in that procedure , i created one macro. but my problem is in the macro1 i used for loop in the for loop some of the process run, after call macro2 do the process, come to macro1 do the second iteration.
but in the macro when i try to putting the "i" which is macro1 for loop variable, its not accepting, i tried create another for loop for macro2 but it is taking all iteartions in the macro2 itself.
but i want to process row by row with 2 macros, can you please help me.
i am attaching macro1 code and macro2 code
[/CODE]
I wrote the code with 1000+ line , but when i add some lines and run its getting Procedure is too large. so i want to create another macro in that procedure , i created one macro. but my problem is in the macro1 i used for loop in the for loop some of the process run, after call macro2 do the process, come to macro1 do the second iteration.
but in the macro when i try to putting the "i" which is macro1 for loop variable, its not accepting, i tried create another for loop for macro2 but it is taking all iteartions in the macro2 itself.
but i want to process row by row with 2 macros, can you please help me.
i am attaching macro1 code and macro2 code
VBA Code:
Sub ENT_MACRO()
Dim ENTPrice As Workbook
Dim ENTPricews As Worksheet
Dim ENTCheat As Workbook
Dim ENTCheatws As Worksheet
Dim ENTMacro As Workbook
Dim ENTMacrows As Worksheet
Dim HR As String
Dim HR1 As String
Dim Weight As String
Dim Weight1 As Double
Dim Weight2 As String
Dim PLfilter As String
Dim rngcell As Range
Dim Condition As Range
Dim i As Long
Dim PN As String
Dim PN1 As String
Dim PN2 As String
Dim PN3 As String
Dim PN4 As String
Set ENTPrice = Workbooks("HP ENT Price book.xlsx")
Set ENTPricews = ENTPrice.Sheets("DailyPurchasePrice")
Set ENTCheat = Workbooks("HPE SKU Matrix.xlsx")
Set ENTCheatws = ENTCheat.Sheets("NEW MATRIX")
Set ENTMacro = Workbooks("ENT.xlsm")
Set ENTMacrows = ENTMacro.Sheets("Sheet1")
ENTMacrows.Rows("2:" & Rows.Count).Delete
a = ENTPricews.Range("F" & Rows.Count).End(xlUp).Row
For i = 2 To a
ENTMacrows.Range("B" & i).Value = ENTPricews.Range("F" & i).Value
HP = "HP-"
ENTMacrows.Range("O" & i).Value = HP & ENTPricews.Range("G" & i).Value
'Short Description
ENTMacrows.Range("C" & i).Value = ENTPricews.Range("J" & i).Value
'Long Description
ENTMacrows.Range("D" & i).Value = ENTPricews.Range("I" & i).Value
'Product Classification
ENTMacrows.Range("G" & i).Value = ENTPricews.Range("W" & i).Value
'List Price
ENTMacrows.Range("AC" & i).Value = ENTPricews.Range("L" & i).Value
'Net Price
ENTMacrows.Range("AB" & i).Value = ENTPricews.Range("O" & i).Value
Call Autofill
Next i
End Sub
[CODE=vba]
Public Sub Autofill()
Set ENTPrice = Workbooks("HP ENT Price book.xlsx")
Set ENTPricews = ENTPrice.Sheets("DailyPurchasePrice")
Set ENTCheat = Workbooks("HPE SKU Matrix.xlsx")
Set ENTCheatws = ENTCheat.Sheets("NEW MATRIX")
Set ENTMacro = Workbooks("ENT.xlsm")
Set ENTMacrows = ENTMacro.Sheets("Sheet1")
a = ENTPricews.Range("F" & Rows.Count).End(xlUp).Row
For i = 2 To a
'PL Filtering
PLfilter = ENTPricews.Range("G" & i).Value
ENTCheatws.Range("$A$1 : $BA$1000000").AutoFilter Field:=1, Criteria1:=PLfilter
With ENTCheatws
For Each Condition In .Range("D2", .Cells(.Rows.Count, "D").End(xlUp)).SpecialCells(xlCellTypeVisible)
If Condition.Value = "CTO or FIO must be in the description. Item has weight (0.1 pound or more) We must convert Kgs into Lbs" Then
If InStr(ENTMacrows.Range("C" & i).Value, "CTO") > 0 Or InStr(ENTMacrows.Range("C" & i).Value, "FIO") > 0 Then
If ENTPricews.Range("AJ" & i).Value <> "" And IsNumeric(ENTPricews.Range("AJ" & i).Value) And ENTPricews.Range("AJ" & i).Value > 0.1 Then
Weight1 = ENTPricews.Range("AJ" & i).Value
ENTMacrows.Range("P" & i).Value = Weight1 * 2.20462262
ENTMacrows.Range("U" & i).NumberFormat = "@"
ENTMacrows.Range("K" & i).NumberFormat = "@"
ENTMacrows.Range("A" & i).Value = Condition.Offset(0, 18).Value
ENTMacrows.Range("J" & i).Value = Condition.Offset(0, 9).Value
ENTMacrows.Range("K" & i).Value = Condition.Offset(0, 10).Value
ENTMacrows.Range("L" & i).Value = Condition.Offset(0, 11).Value
ENTMacrows.Range("T" & i).Value = Condition.Offset(0, 18).Value
ENTMacrows.Range("U" & i).Value = Condition.Offset(0, 19).Value
ENTMacrows.Range("X" & i).Value = Condition.Offset(0, 22).Value
ENTMacrows.Range("Y" & i).Value = Condition.Offset(0, 23).Value
ENTMacrows.Range("Z" & i).Value = Condition.Offset(0, 24).Value
ENTMacrows.Range("AF" & i).Value = Condition.Offset(0, 30).Value
ENTMacrows.Range("AI" & i).Value = Condition.Offset(0, 33).Value
ENTMacrows.Range("AL" & i).Value = Condition.Offset(0, 36).Value
ENTMacrows.Range("AM" & i).Value = Condition.Offset(0, 37).Value
ENTMacrows.Range("AN" & i).Value = Condition.Offset(0, 38).Value
ENTMacrows.Range("AO" & i).Value = Condition.Offset(0, 39).Value
ENTMacrows.Range("AP" & i).Value = Condition.Offset(0, 40).Value
ENTMacrows.Range("AQ" & i).Value = Condition.Offset(0, 41).Value
Exit For
End If
End If
Else
ENTMacrows.Range("U" & i).NumberFormat = "@"
ENTMacrows.Range("K" & i).NumberFormat = "@"
ENTMacrows.Range("A" & i).Value = Condition.Offset(0, 18).Value
ENTMacrows.Range("J" & i).Value = Condition.Offset(0, 9).Value
ENTMacrows.Range("K" & i).Value = Condition.Offset(0, 10).Value
ENTMacrows.Range("L" & i).Value = Condition.Offset(0, 11).Value
ENTMacrows.Range("T" & i).Value = Condition.Offset(0, 18).Value
ENTMacrows.Range("U" & i).Value = Condition.Offset(0, 19).Value
ENTMacrows.Range("X" & i).Value = Condition.Offset(0, 22).Value
ENTMacrows.Range("Y" & i).Value = Condition.Offset(0, 23).Value
ENTMacrows.Range("Z" & i).Value = Condition.Offset(0, 24).Value
ENTMacrows.Range("AF" & i).Value = Condition.Offset(0, 30).Value
ENTMacrows.Range("AI" & i).Value = Condition.Offset(0, 33).Value
ENTMacrows.Range("AL" & i).Value = Condition.Offset(0, 36).Value
ENTMacrows.Range("AM" & i).Value = Condition.Offset(0, 37).Value
ENTMacrows.Range("AN" & i).Value = Condition.Offset(0, 38).Value
ENTMacrows.Range("AO" & i).Value = Condition.Offset(0, 39).Value
ENTMacrows.Range("AP" & i).Value = Condition.Offset(0, 40).Value
ENTMacrows.Range("AQ" & i).Value = Condition.Offset(0, 41).Value
End If
Next
End With
Next i
End Sub