Hi,
Below VBA do not do all commands. If I do it by break, it works correctly. Please comments your solutions. Thanks.
Below VBA do not do all commands. If I do it by break, it works correctly. Please comments your solutions. Thanks.
Code:
Dim a, b, c, d, e, f, g, h, k, m
'FX
k = 0
m = 0
k = Workbooks(1).Sheets("FX").Range("A1", Workbooks(1).Sheets("FX").Range("A1").End(xlDown)).Rows.Count
m = Workbooks(1).Sheets("FX").Range("P1", Workbooks(1).Sheets("FX").Range("P1").End(xlDown)).Rows.Count
If k > m Then
Workbooks(1).Sheets("FX").Range("P" & m & ":U" & m).Copy
Workbooks(1).Sheets("FX").Range("P" & m + 1 & ":U" & k).PasteSpecial xlPasteFormulas
Else
Workbooks(1).Sheets("FX").Range("P" & k + 1 & ":U" & m) = ""
End If
'PCDOWN5
a = 0
b = 0
a = Sheets("PCDOWN5").Range("A1", Workbooks(1).Sheets("PCDOWN5").Range("A1").End(xlDown)).Rows.Count
b = Sheets("PCDOWN5").Range("V1", Workbooks(1).Sheets("PCDOWN5").Range("W1").End(xlDown)).Rows.Count
If a > b Then
Sheets("PCDOWN5").Range("W" & b & ":Y" & b).Copy
Sheets("PCDOWN5").Range("W" & b + 1 & ":Y" & a).PasteSpecial xlPasteFormulas
Else
Workbooks(1).Sheets("PCDOWN5").Range("W" & a + 1 & ":Y" & b) = ""
End If
'PCDOWN7
c = 0
d = 0
c = Sheets("PCDOWN7").Range("A1", Sheets("PCDOWN7").Range("A1").End(xlDown)).Rows.Count
d = Sheets("PCDOWN7").Range("V1", Sheets("PCDOWN7").Range("W1").End(xlDown)).Rows.Count
If c > d Then
Sheets("PCDOWN7").Range("W" & d & ":W" & d).Copy
Sheets("PCDOWN7").Range("W" & d + 1 & ":W" & c).PasteSpecial xlPasteFormulas
Else
Sheets("PCDOWN7").Range("W" & c + 1 & ":W" & d) = ""
End If
'PCDOWN4
e = 0
f = 0
e = Sheets("PCDOWN4").Range("A1", Sheets("PCDOWN4").Range("A1").End(xlDown)).Rows.Count
f = Sheets("PCDOWN4").Range("V1", Sheets("PCDOWN4").Range("W1").End(xlDown)).Rows.Count
If e > f Then
Sheets("PCDOWN4").Range("W" & f & ":W" & f).Copy
Sheets("PCDOWN4").Range("W" & f + 1 & ":W" & e).PasteSpecial xlPasteFormulas
Else
Sheets("PCDOWN4").Range("W" & e + 1 & ":W" & f) = ""
End If
'PCDOWN6
g = 0
h = 0
g = Sheets("PCDOWN6").Range("A1", Sheets("PCDOWN6").Range("A1").End(xlDown)).Rows.Count
h = Sheets("PCDOWN6").Range("V1", Sheets("PCDOWN6").Range("V1").End(xlDown)).Rows.Count
If g > h Then
Sheets("PCDOWN6").Range("V" & h & ":AC" & h).Copy
Sheets("PCDOWN6").Range("V" & h + 1 & ":AC" & g).PasteSpecial xlPasteFormulas
Else
Sheets("PCDOWN6").Range("V" & g + 1 & ":AC" & h) = ""
End If
Last edited by a moderator: