Hi,
Would anyone help me to create a cut and paste loop code.
In the following code you would see one same action repeated many times. I´m just including some lines.
Thanks in advance,
Regards
Sub ImportData()
'
' ImportData Macro
'
'
Sheets("Info for MACro").Select
Range("F1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Macro Sheet").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Cut
Range("A1").Select
Selection.End(xlDown).Select
Range("A161").Select
ActiveSheet.Paste
Range("B161").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Range("A161").Select
Selection.End(xlDown).Select
Range("A321").Select
ActiveSheet.Paste
Action continues up to:
Range("B28801").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range("B28801").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("A28801").Select
Selection.End(xlDown).Select
Range("A28961").Select
ActiveSheet.Paste
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="*", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1)), TrailingMinusNumbers:=True
Range("A1:E1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Forecast Table").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Forecast Qty II").Select
Range("A7").Select
Application.CutCopyMode = False
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Range("A5").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Distributor").ShowDetail = _
False
Sheets("Forecast $$$ II").Select
Range("C8").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Range("A4").Select
ActiveSheet.PivotTables("PivotTable2").PivotFields("Distributor").ShowDetail = _
False
Sheets("Forecast Qty II").Select
Range("A1").Select
End Sub
Would anyone help me to create a cut and paste loop code.
In the following code you would see one same action repeated many times. I´m just including some lines.
Thanks in advance,
Regards
Sub ImportData()
'
' ImportData Macro
'
'
Sheets("Info for MACro").Select
Range("F1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("Macro Sheet").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Application.CutCopyMode = False
Selection.Cut
Range("A1").Select
Selection.End(xlDown).Select
Range("A161").Select
ActiveSheet.Paste
Range("B161").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Range("A161").Select
Selection.End(xlDown).Select
Range("A321").Select
ActiveSheet.Paste
Action continues up to:
Range("B28801").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range("B28801").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("A28801").Select
Selection.End(xlDown).Select
Range("A28961").Select
ActiveSheet.Paste
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="*", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, _
1)), TrailingMinusNumbers:=True
Range("A1:E1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Forecast Table").Select
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Forecast Qty II").Select
Range("A7").Select
Application.CutCopyMode = False
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Range("A5").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Distributor").ShowDetail = _
False
Sheets("Forecast $$$ II").Select
Range("C8").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Range("A4").Select
ActiveSheet.PivotTables("PivotTable2").PivotFields("Distributor").ShowDetail = _
False
Sheets("Forecast Qty II").Select
Range("A1").Select
End Sub