Excel Cut and Paste Loop

Gabo

New Member
Joined
Jul 28, 2011
Messages
1
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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
there are too many selection. cell)s) need not be selected either to cut or paste in VBA.

what is the logic of selection for either copying or for pasting or are these adhocs.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top