How To Create Macro to Search, Copy, & Paste
Solved/Closed
Paul
-
Feb 6, 2010 at 12:15 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Feb 10, 2010 at 05:26 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Feb 10, 2010 at 05:26 PM
Related:
- How To Create Macro to Search, Copy, & Paste
- Create skype account with gmail - Guide
- How to search google usa - Guide
- How to search nearby friends on facebook - Guide
- How to search for words on a page - Guide
- How to create group chat in viber - Guide
3 responses
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
Feb 6, 2010 at 08:31 PM
Feb 6, 2010 at 08:31 PM
The full logic is not clear. I have just "modified" your macro so that you can understand the changes(though the whole macro can me tweaked a lot).
when you start the macro the macro will ask what number you want to search type there the invoice number e;.g. 33629
But I have one problem ok. you find 33629 in sheet2 and copy the entire row
goto sheet1(2) and paste the above row in the row where the first cell is A194 in the second sheet. ok so far.
But when you select another number where do you want to copy the row in sheet1(2). this is not clear.
I suggest you keep your original workbook safe some where so that it can be retrieved.
then run the macro and see whether it is ok. if it is ok then answer my qeustion in bold undelined above. the macro can be still more modified.
In the macro I have put a single apostrophe in the beginning of some lines so that they will nOT be operable. You can delete these lines later once you understand the macro
the macro at the present stage is
when you start the macro the macro will ask what number you want to search type there the invoice number e;.g. 33629
But I have one problem ok. you find 33629 in sheet2 and copy the entire row
goto sheet1(2) and paste the above row in the row where the first cell is A194 in the second sheet. ok so far.
But when you select another number where do you want to copy the row in sheet1(2). this is not clear.
I suggest you keep your original workbook safe some where so that it can be retrieved.
then run the macro and see whether it is ok. if it is ok then answer my qeustion in bold undelined above. the macro can be still more modified.
In the macro I have put a single apostrophe in the beginning of some lines so that they will nOT be operable. You can delete these lines later once you understand the macro
the macro at the present stage is
Sub TEST() Dim j As Double j = InputBox("type the number you want e.g. 33629") 'Range("AM5:AS5").Select 'ActiveCell.FormulaR1C1 = "33629" Sheets("Sheet2").Select Cells.Find(What:=j, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate 'Rows("6:6").Select 'Range("C6").Activate 'Selection.Copy ActiveCell.EntireRow.Copy Worksheets("sheet1(2)").Select Range("A194").PasteSpecial End Sub
Thanks :) Is there a code I could add to it to tell it. If cancel is pressed or if the top corner x is press not to glitch out. Just to cancel macro?
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Feb 10, 2010 at 05:26 PM
Feb 10, 2010 at 05:26 PM
Just underneath
j = InputBox("type the number you want e.g. 33629")
you can add
If (j = "") Then Exit Sub
j = InputBox("type the number you want e.g. 33629")
you can add
If (j = "") Then Exit Sub