Find, Copy Row Macro
Oct 8, 2009
I know this is probably something easy, but I can't seem to find the answer. I am trying to create a macro that will look for the number 5 in column C and if found, copy and paste the entire row below. I need it to find all instances of the number 5 in column C and copy the row below.
I found the code below that seemed like what I needed but when I changed it to look for the number 5, it didn't work. I have tried putting 5 in quotes "5" and that doesn't help. Below is the code and sample data.
Sub OT()
If WorksheetFunction.CountIf(Columns(3), 5) > 0 Then
Dim xRow&
xRow = Columns(3).Find(What:= 5, LookIn:=xlFormulas).Row
Rows(xRow + 1).Insert
Rows(xRow).Copy Rows(xRow + 1)
End If
End Sub
Original Data
J4R N166888520J4R N166888180J4R N40018524J4R N400185176J4R N40018558
What I want it to look like
J4R N166888520J4R N166888520J4R N166888180J4R N40018524J4R N400185176J4R N40018558J4R N40018558
View 9 Replies
ADVERTISEMENT
May 28, 2007
I have a spreadsheet with 20 sheets, with each sheet representing work done by an individual. The sheet would contain all the tasks and the percentage of work alotted. I now need to capture all these in a summary spreadsheet BUT only if the task is "IN PROGRESS" which is indicated in one of the cells.
Currently, we're doing it manually and it is a pain to go through all the names and copying the rows one by one. The summary should show the names with the corresponding project name and allocated time (copy whole row).
View 13 Replies
View Related
Oct 30, 2007
I'm trying to come up with a macro which will go through column A once searching for a value (ex. "apple") and upon finding a cell with that value, take cells 79-100 from that row, copy them to cells 82-103 of the next row, and delete the row which contains the value.
I believe the functions I need to use are:
View 13 Replies
View Related
Nov 16, 2012
I have the following code. It runs fine and I get the popup msg at the end but it doesn't do what I need.
Range w2 is a date. I want the macro to search for this date in Sheet2 just in Column B and when found copy everything on the row it is found down to the end of the worksheet whatever row that might be and then go to sheet1 and paste this below the last used row!
Code:
Sub test222()
Dim FindWord As String, Found As Range
Dim wsDest As Worksheet, ws As Worksheet, wb As Workbook
Dim Nextrow As Long, Lastrow As Long
Set ws = ThisWorkbook.Sheets("Sheet2")
[Code] ........
View 3 Replies
View Related
Aug 21, 2007
I'm using Macros. I have a workbook composed of three sheets "Anzahl" "Tabelle 1" and "Sheet1".
For "Sheet1" I want to create a macros that will search for the word "Sonntag" in the B column and then copy the corresponding values in the C and H column to a different part of the sheet. I have used the following code
Sub SearchAndInsert()
Dim i, k, k1 As Integer
k = 3
k1 = 3
For k = 1 To 355
If UCase( Range("b" & k).Value) = "Sonntag" Then
Range("c" & k).Select
Selection.Copy
Range("p" & k1).Select
ActiveSheet.Paste
Range("h" & k).Select
Selection.Copy
Range("q" & k1).Select
ActiveSheet.Paste
k1 = k1 + 1
End If
Next
End Sub
However, everytime I hit the run button or press F5, nothing really happens and nothing is copied.
View 8 Replies
View Related
Mar 7, 2007
I have is two spreadsheets with different data on them, but the only connector is the user ID, so I want the cell I select with the user ID to be copied it then switches to the other spreadsheet and finds the copied selection, it then takes the columns on the selection of A to J and pastes them back in the other columns in the other spreadsheet.
My only real problem is that I can't get it to use the selection.copy in the find to select the cells I need, any help would be great, thanks.
Code ( i put spaces bewteen the other parts and find function so you could easily see it):
Sub Macro1()
Selection.Copy
Windows("EMERA-employees-asof-06-Mar-2007.xls").Activate
Cells.Find(What:="(I want this to be selection.copy)", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Columns("A:J").Select
Application.CutCopyMode = False
Selection.Copy
Windows("SMSReportResults.xls").Activate
ActiveCell.Offset(0, 6).Range("A1").Select
ActiveSheet.Paste
End Sub
View 9 Replies
View Related
Apr 27, 2007
The macro finds the value in cell D11 (which is the name of a product) in a worksheet called "Summary1". It then looks for this value in another worksheet called "Output", specifically in a column with a named range called "Products". If the value being searched is found in the "Products" named range column (in the worksheet "Output"), the code below copies the entire row for it, to another sheet called "OutputSummary1". I would like to change the code as follows:
1) Instead of copying the entire row, for which the searched for value is found, from the sheet "Output" to the sheet "SummaryOutput1", I would like to instead only copy the values in columns A, B, and E to the sheet "OutputSummary1". Also, I would like the values to be pasted pastespecial so that the formulas in the sheet "Output" are not copied over, and only the values are copied.
2) Secondly, I would like to know how to perform the find procedure (searching for cell D11 contents) on all sheets in the same workbook beginning with the word "Summary" (There will be worksheets called Summary1, Summary2, Summary3, etc. that the macro should be performed on.) As well, the pasting should be perfomed on all respective sheets called OutputSummary1, OutputSummary2, OutputSummary3, etc.
Sub CopyPaste()
With Worksheets(1).Range("Products")
Set c = .Find(Worksheets("Summary1").Range("D11").Value, LookIn:=xlValues) 'this identifies the value D11 in worksheet called Summary1
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.EntireRow.Copy Destination:=Worksheets("OutputSummary1").Range("a" & Worksheets("OutputSummary1").Range("a65536").End(xlUp).Row + 1)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
View 7 Replies
View Related
Jul 11, 2014
See attached spreadsheet for reference : MacroHelp.xlsx
I would like the macro to look in column I, and when it finds "TRUE", I'd like it to copy and paste values in all the cells to the left of it.
Reason being is that I want to rid the row of its formula, so the next time someone changes the info (the date the vlookup is searching for) in the tabs those cells are referring to, I will not lose the data it returned previously.
Really all I want is to copy and paste the values in the lowermost row of new information for each plant, but this is the best way I can currently think of.
I've removed the tabs the cells in columns B-G are referring to for sensitivity's sake.
View 2 Replies
View Related
Feb 10, 2014
I am in need of a macro that will:
1. Check cell B1 for my named regions
2. Find all citys in that region from another worksheet
3. Copy the specific details
4. Highlight the information that has just been copied and create a bar chart for comparison
Data to be picked up from "Inc 8%" sheet.
Headings are the same on both the worksheet the information is being taken from and being pasted to.
I need City, Year 1 Turnover - Year 10 Turnover data to be copied.
Region Help.xlsm
View 2 Replies
View Related
May 13, 2009
find a string and copy certian string to next cell i have tried something which can copy but unforunately that is copying whole cell not certian string.
I have data of 500 rows and i have data till A,B,C,D and E.Please ignore all the other rows which are of no use except E in Column E i just need Reference : A0000000:1 to be copied to next column beside to it that means in Column F.
View 2 Replies
View Related
May 21, 2009
I am attempting to do is have a macro (Via Command button) go through column A to find the word "TOTAL". Once that is found I want it to offset by 3 rows (from the word "TOTAL") to grab the number and place it into column B.
View 2 Replies
View Related
Jul 26, 2013
I want to find data from a certain point and paste this to a cell. My objective is to get all the data on too one row. This row is always 1 in col M called Run#. The find locations never change, just the data being copied always changes . Heres example,
In col K find FHBASC and look across to the right 3 cells in col N and copy.
Look in col M and find 1, paste above copied data into col GI.
Then move down rows to next FHBASC and repeat process until end of sheet.
If I can get a very basic simple macro to do this, then hopefully I can just re write to suit my other data.
View 9 Replies
View Related
Mar 24, 2009
I have 10 worksheets. They are labelled 'FEB', 'MAR', 'APR', etc...to 'NOV' (NB: JAN & DEC not needed). In column "G" on all these sheets I have the data as "CURRENT" or "OVERDUE". The first 3 rows on every sheet are headers, so the data starts at 'G4' on every sheet.
I then have an "OUTSTANDING" sheet which will display all of the "OVERDUE" items from the various months. I have an UPDATE_Click() event which when actioned needs to search all the column Gs in the month sheets and then copy the data from column 'B' to 'F' of the corressponding row to an "OVERDUE" result. The data from B-F then needs to be pasted in the next available row on the "OUTSTANDING" worksheet (starting at row 4, as first 3 rows are headers with merged and unmerged cells).
Nothing fancy, when the search go does the column and hits a blank cell that means its the end of the list and can move on to the next month.
View 9 Replies
View Related
Feb 1, 2009
I am working on getting a macro to find a name in column "B" and once found copy its row to another sheet. I have been working on an "IF" statement that checks for the given name and if true copies the row. I can not get it to keep checking and then stop using "loop" What i got so far:
View 2 Replies
View Related
Mar 4, 2009
I have a workbook with many sheets in it. Within each sheet there is a cell with the Text "March 09" there are then 3 cells to the right of this cell with relevant information. Is there a Macro that can search for this text March 09, then copy this and the 3 cells to the right of it and paste special this information 1 cell below for all 4 cells.
View 2 Replies
View Related
Nov 11, 2009
I have a 'rota' worksheet that includes staff names and their rostered hours on all dates through the month.
On each date of the month I need excel to find that date in column A and then look across the row to find any cells that aren't blank. When the cell has a value I need the name above it in row 1 and the value (number of hours) itself to copy across to a 'daily activities' sheet. The date is autopopulating on this sheet in cell H5.
The name needs to drop into column A and the hours worked into column B. I would like the first cell to be A9 and then down from there with no spaces in between names. The other info on the sheet will then complete itself using the name that has been dropped in using VLookup.
I'm presuming I can use a macro to do this for me but am really struggling where to start with it, and how to ignore blank cells as they will change cells on a monthly basis.
View 7 Replies
View Related
Nov 13, 2009
I am comfortable with getting a macro to copy & paste where I need it to, however how to get the macro to recognise when a certain value has stopped.
For example in Column B on "DataDrop" are all the divisions that exist in my company i.e East Anglia, Essex, London etc. There is an empty row between each division.
View 4 Replies
View Related
May 13, 2009
I am in the process of writing a VBA code(I should I am fairly new to this code writing!!!).What I need to be able to do is below.(enclosed please find a output in an xls file) What I should be able to do is below:
1.Find the text "Cash(No Listing)(Monthly)"
2. Offset to the 13th Column after that
3.Select the value in this column ,copy the value
4.Go to a row above and move one column to the left i.e.offset (-1,-1) and move 12 column backwards i.e.offset(0,-12)
5.Copy the value in 3 above to this entire range
6.Repeat this process for the entire file
My code is as below.Let me know where am I making a mistake. Just to let you know that this code performs the job well for the first entry i.e in the yellow makde area and doesn't do the job for any further entries .Llooks like I have some problem with the loop but not sure as to whats happening!
View 3 Replies
View Related
Dec 16, 2008
I would like to create macro, where it would on macro run copy text from active cell and find that value in another sheet (in column H) and select that cell.
What I did is this:
View 5 Replies
View Related
Nov 5, 2013
Let's say sheet - "delivery" - has a row1 that includes all possible delivery days. So A1 is 1.9.2013, B1 is 15.9.2013, C1 is 1.10.2013 and so on.
I want to make a macro, that will gradually go through whole row 3 in sheet "delivery" and look for "A1" date in sheet "Orders". Sheet "orders" have for example in column B the date of delivery, and in column C product of the delivery.
I want the macro to find all deliveries with "A1" date, and paste all products that will be delivered on this day under cell A1 (sheet delivery). then move on to the cell B1 (sheet delivery) - find all orders in sheet orders, that will be delivered on B1 date, and list all products with this delivery date under cell B1 (sheet delivery).
Example:
Sheet order
A
B
C
Date of delivery
Product
1.9.2013
orange
[Code] ........
Unfortunately simple Pivot table is not able to do this simple list.
View 3 Replies
View Related
Dec 30, 2011
how to work macros or VBA
I have a workbook with multiple sheets named by month and year that I use to keep track of loans I work with at a bank. In these sheets I have info such as:
Column B = due date
Column D = loan# A
Column E = loan# B
Column F = status
Column H = followup needed
(Columns A,C, and G aren't important for the current need)
What I am trying to do is create a main sheet (TRACKER) that all I will have to do is press a macro button and it will pull info for each loan that is in a pending status.
I need a macro that will search column F (Status) on all sheets and find each instance of "Pending" and once that is done, copy rows B,D,E, and H in each "Pending" instance and copy them to their designated area on my TRACKER sheet. After that is done I need it to continue to the next "pending" instance and do the same on the next available line on my TRACKER sheet.
The overall goal would be that everyday I can press the macro and it will repopulate the sheet with the current pending items (as each day I will change pending status' to complete and no longer need to track it the next day).
I already have the tracker sheet set up and ready to go with the spaces as follows:
Column G&H = Merged cells where due date will need to go
Column I&J = Merged cells where loan# A will need to go
Column K&L = Merged cells where loan# B will need to go
Column M thru S = Merged cells where followup needed will need to go
View 9 Replies
View Related
Mar 23, 2012
Excel 2007, Windows XP Pro
Dim strLoan As String
Dim longCat As Long
Dim rHere As Range
Range("A1").Select
[Code] .....
I can see the cursor move to all the desired cells when this macro executes; it just isn't dropping any data where it should be. I have been working at this stage for the last five hours with no success. I don't know whether my copy-paste methodology is broken or if it is my selection criteria
View 1 Replies
View Related
Nov 4, 2009
I want to copy some data from internet and paste it in to worksheet location Range A1:A30. the data look like following information.
LocationKuwaitP.O.Box:4819 SafatAddress:ShuwaikhTel:-22253580Fax:-24343645Category:CONSTRUCTION COMPANIES
the above information have following header ie. Location, P.O.Box, Address, Tel, Fax and Category.
every time one of the header inforamtion is missing ie. Address or P.O.Box, Or Fax, due to this problem every time cell address of information aganist header is change. supose in first copy/paste Tel inforamtion is in A15, but second time it may be on A13, and 3rd time it may be on A17 and so on.
I want to make a macro which search header ("Location", "P.O.Box", "Address", "Tel", "Fax", "Category" ) from a Range A1:A30. than down two steps to copy header information (75325412) and paste in fixed cell location C1:C5 (C1=Name, C2=Location, C3: P.O.Box, C4=Address, C5=Tel, C6=Fax, C7=Category) in same sheet. and repeat the steps to copy information aganist header from all header in Range A1:A30.
View 9 Replies
View Related
Dec 11, 2013
I have the following code, so far:
Code:
Sub CopyPasteValue()
Dim ARow
Dim AColumn
Dim BRow
Dim BColumn
Dim Value
AColumn = 1
[Code]....
What I want it to do is to start in cell B1 and look down until it finds a non-blank cell; copy the contents of that cell. I then need it to go to the same row Col A and go down from until it finds the first non-blank cell then paste into the corresponding cell in Col B. It should continue this way through the rest of the worksheet. There is no set pattern to say to go down 5 rows or such. Also the number of pastes in each step is variable from 1 to ??
In my worksheet, the first non-blank cell in Col B is cell B3 and the first non-blank cell in Col A is A7. The paste should occur in cells B7:B10 because the next non-blank cell in Col A is A11.
View 2 Replies
View Related
Feb 2, 2010
I have a base document that i can import another data document with a button (this is working).
I then have another WS ("search") in the base document with lots of identifiers which I want to use as my search range to look through the document that I just imported (column A).
I need a msg to ask the user what month they would like to find the $ value on (Ie, January) in the imported WS... this way it doesnt copy the entire line only cell in the selected month column.
Then I want to the user to be able to click a button that will check through the identifiers on the "search" WS and if the same identifier appears in the imported WS in column A, then for the $ value in the column selected to be copied to the search Range work sheet.
If the idenfifier is not matched then in place of the $ value copied can be the string "no in XXX WS" .
I have attached the document with dummy data in each work sheet with details more cleary what I have meantion above.
View 9 Replies
View Related
Aug 6, 2007
The following macro does what it is designed to do and needs to be run from a control sheet called "Guide". When I run it from this Guide sheet it stops at around row 53 (out of 1400 rows) on each of the specified sheets in the macro. I have struggled with this problem and have now discovered that the macro will run correctly when run from one of the worksheets specified in the array, e.g. sheet "200 and 100".
Sub Calculateclosingtrades1()
Dim r As Long, c As Integer, LastRow As Long, rcheck As Long
LastRow = Range("J65536").End(xlUp).Row
Dim shtTemp As Worksheet
Dim vntName As Variant
For Each vntName In Array("200 and 100", "100 and 50", "50 and 25", "40 and 20", "20 and 10", "15 and 10", "18 and 9", "200 only", "100 only", "50 only", "40 only", "25 only", "20 only", "15 only").............
View 7 Replies
View Related
Jan 22, 2007
I want to copy and paste from one sheet to another based on column a using a macro copy button.
E.g. if column a value = apple then copy that row into the apple sheet.
View 9 Replies
View Related
Dec 14, 2008
giving me a macro to find a word in a sentence by using the "FIND" method.
For example I have a sentence say "I am happy" in which I have to search whether any of 2 words say "Happy" or "Sad" is there or not. If the sentence contains any of these words, then that row has to be highlighted.
View 9 Replies
View Related
Feb 18, 2008
I have a macro that inserts a formula on the first row and then copies it down. The problem is the row count is variable but I know it won't exceed 5000 so I just copy it down 5000. For the blank rows I get the ugly #NAME, #VALUE, etc errors.
I know there are ways to supress those error messages, but how about a way so that the macro checks to see how many rows are populated so it doesn't copy down on the blank rows.
View 9 Replies
View Related
Dec 14, 2008
I have 8000 data in a column.
For example.
red shoes
tennis shoes
running shoes
tennis balls
running shorts
I want to find & copy the sentences say:
1.With word shoes
2.With word running
3.With words tennis
View 5 Replies
View Related