ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy and paste within macros (https://www.excelbanter.com/excel-programming/408239-copy-paste-within-macros.html)

D'Artagnan

copy and paste within macros
 
While recording a macro:
1) a *.txt file is opened
2) after opening the file a "FIND where ANY =" is used then I click on FIND
ALL
3) it get a long list of cells.... then by holding SHIFT and clicking the
last cell it highlights those lines where the "ANY =" string appears.
4) The cursor is placed on any of the highlighted cells and PASTED on
another column of the same worksheet, a column gets copied with only those
cells with an "ANY =".
The worksheet is saved...as well as the Macro.
However when the macro is run it only displays one line........the first
line with "ANY ="
Is it possible to do a FIND and then COPY the range of cells from the FIND
Pop Up Window?
Thanks a lot...

[email protected]

copy and paste within macros
 
On Mar 24, 3:20*pm, D'Artagnan
wrote:
While recording a macro:
1) a *.txt file is opened
2) after opening the file a "FIND where ANY =" is used then I click on FIND
ALL
3) it get a long list of cells.... then by holding SHIFT and clicking the
last cell it *highlights those lines where the "ANY =" string appears.
4) The cursor is placed on any of the highlighted cells and PASTED on
another column of the same worksheet, a column gets copied with only those
cells with an "ANY =".
The worksheet is saved...as well as the Macro.
However when the macro is run it only displays one line........the first
line with "ANY ="
Is it possible to do a FIND and then COPY the range of cells from the FIND
Pop Up Window?
Thanks a lot...


Sub RunIt()

Sheets("Sheet2").Select
Range("A2").Select
Sheets("Sheet1").Select
Range("A2").Select
' or where ever you have the "ANY =" value.

Do

If ActiveCell.Value = "ANY =" Then
ActiveCell.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
ActiveCell.Offset(1,0).Select
Sheets("SHEET1").Select
ActiveCell.Offset(1,0).Select
End If

If ActiveCell.Value < "ANY =" Then
ActiveCell.Offset(1,0).Select
End If

Loop Until ActiveCell.Offset(5, 0).Value = ""


All times are GMT +1. The time now is 10:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com