Hi there,
I am trying to compile 5 macro into one macro but had failed horribly so far. Currently, the 5 macro that I have are to update a table containing 5 days. Each macro for one day. The 5 macro work fine as it grab the data from another excel file and paste it in but what I want is to reduce the 5 macro into just 1.
So far, I have been trying to do this by setting up some kind of condition. The condition that I used is IF condition. However when I compiled the macro into 1 and use the IF as the condition, excel will demand me to update all 5 days at once instead of just one day.
Please help. Using WinXP and Excel 2007. Below is the compiled macro code that I used to attempt. It is only for 3 days instead of 5 days since it doesn't make a difference.
I am trying to compile 5 macro into one macro but had failed horribly so far. Currently, the 5 macro that I have are to update a table containing 5 days. Each macro for one day. The 5 macro work fine as it grab the data from another excel file and paste it in but what I want is to reduce the 5 macro into just 1.
So far, I have been trying to do this by setting up some kind of condition. The condition that I used is IF condition. However when I compiled the macro into 1 and use the IF as the condition, excel will demand me to update all 5 days at once instead of just one day.
Please help. Using WinXP and Excel 2007. Below is the compiled macro code that I used to attempt. It is only for 3 days instead of 5 days since it doesn't make a difference.
Code:
Sub Macro4()
'
' Macro4 Macro
'
'
Application.ScreenUpdating = False
''''''''''''''''''''''''''''''''''''''
'FIRST DAY
'''''''''''''''''''''''''''''''''''''''
If Range("B63").Value = "0" Then
Windows("Test2.xls").Activate
Range("B3:J3").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Day 1").Activate
Range("B4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
End If
If Range("B66").Value = "0" Then
Windows("Test2.xls").Activate
Range("B5:J5").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Day 1").Activate
Range("B18").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
End If
''''''''''''''''''''''''''''''''''''''
'SECOND DAY
'''''''''''''''''''''''''''''''''''''''
If Range("B63").Value = "1" Then
Windows("Test3.xls").Activate
Range("B3:J3").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Day 2").Activate
Range("C4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
End If
If Range("B66").Value = "1" Then
Windows("Test3.xls").Activate
Range("B5:J5").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Day 2").Activate
Range("C18").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
End If
''''''''''''''''''''''''''''''''''''''
'THIRD DAY
'''''''''''''''''''''''''''''''''''''''
If Range("C64").Value = "2" Then
Windows("Test4.xls").Activate
Range("B3:J3").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Day 3").Activate
Range("D4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
End If
If Range("C67").Value = "2" Then
Windows("Test4.xls").Activate
Range("B5:J5").Select
Application.CutCopyMode = False
Selection.Copy
Windows("Data Day 3").Activate
Range("D18").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
End If
End Sub
Last edited: