Hello again
I am trying to call one macro from another however it is not running through the second macro.
The macro I am calling is:
And I am trying to call it with the following section of code
I am sure I am missing something simple but I can't seem to find it anywhere.
Mark
I am trying to call one macro from another however it is not running through the second macro.
The macro I am calling is:
Code:
Sub correction()
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
LR = ws.Range("A65536").End(xlUp).Row
For Each cell In ws.Range("A2:A" & LR).Cells
If ws.Range("I2") <> "" Then
If cell.Value <> cell.Offset(0, 6).Value Then
ws.Range(Cells(cell.Row, "c"), Cells(cell.Row, "ab")).Insert
ws.Range(Cells(cell.Row, "j"), Cells(cell.Row, "ab")).Value = 999
cell.Offset(0, 6).Value = cell.Value
cell.Offset(0, 8).Value = cell.Offset(0, 1).Value
If ws.Range("C2") = "" Then
cell.Offset(0, 2).Value = cell.Offset(1, 2).Value
Else
cell.Offset(0, 2).Value = cell.Offset(-1, 2).Value
End If
Else
If cell.Offset(0, 1).Value <> cell.Offset(0, 8).Value Then
ws.Range(Cells(cell.Row, "c"), Cells(cell.Row, "ab")).Insert
ws.Range(Cells(cell.Row, "j"), Cells(cell.Row, "ab")).Value = 999
cell.Offset(0, 6).Value = cell.Value
cell.Offset(0, 8).Value = cell.Offset(0, 1).Value
cell.Offset(0, 2).Value = cell.Offset(-1, 2).Value
If ws.Range("C2") = "" Then
cell.Offset(0, 2).Value = cell.Offset(1, 2).Value
Else
cell.Offset(0, 2).Value = cell.Offset(-1, 2).Value
End If
End If
End If
End If
Next cell
ws.Range("A2:AA8785").Font.Bold = False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
And I am trying to call it with the following section of code
Code:
For Each ws In ActiveWorkbook.Worksheets
ws.Range("A1:AB8785").Copy
ws.Range("A1:AB8785").PasteSpecial Paste:=xlPasteValues
ws.Range("C2:AB8785").Sort Key1:=Range("G2"), Order1:=xlAscending, Key2:=Range("I2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
If ws.Range("D2").Value = 0 Then
ws.Delete
End If
ws.Range("A1").Select
Call correction
Next ws
I am sure I am missing something simple but I can't seem to find it anywhere.
Mark