VBA To Find Last Row Of Data And Copy Range
Mar 20, 2013What would the VBA code be to find the last row of data and have it copy range A2:E(last row)?
View 2 RepliesWhat would the VBA code be to find the last row of data and have it copy range A2:E(last row)?
View 2 RepliesI am looking for a formula function or a vba code where:
- In workbook1 find the first cell that is empty between range A7 -
A10,
- In workbook2, in Range G10- G13: find the word "Day1".
- If the word "Day1" exists in cells G10 or G11 or G12 or G13, copy
the particular cell or cells where "Day1" exists to the first found
empty cell or cells in range A7-A10 in workbook1.
Lets suppose cells A8, A9, A10(workbook1) are empty cells, that means
A8 is the first empty cell.
And G10,G11,G12, G13 (workbook2) have the word "Day1"
Then,
Copy cell G10 into cell A8
Copy cell G11 into cell A9
Copy cell G12 into cell A10
I need method, using a button, that looks at a cell--say EO2, for example--, looks back on a master worksheet at a specified row and range for a match, then looks at the information from a specified range below the matching cell (The information in this column will either be blank or have an "X" in the cell), and then those rows that do not have an "X" will be hidden in the corresponding rows in the working worksheet. Therefore, if at any time the value in "EO2" ever changes, then it will automatically find a new match and repopulate and hide information as before. About 130 columns will have its own button so that a "query" can be made that depends on the information in a particular cell in that column.
The master worksheet now has matrix of 287 rows and 58 columns. Each row is for an operating procedure and each column shows a job code. An "X" in a coordinate cell for a column/row shows whether that job code is responsible for knowing that operating procedure. So, on the working sheet, an employee's primary job code is given underneath his or her name. When the button is pushed, all the operating procedures not required for a given person will be hidden and only the required ones will remain visible--grouped, if you will. Qualification dates will be easier to see now that the information is consolidated. Whenever someone transfers to a new position, a new code will be inputed on the working sheet. When the button is pushed, a new grouping will result. Any operating instructions that overlap will still have qualification dates, so that information will not need to be transcribed.
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.
Another question where i think my logic is ok i'm just not sure on the syntax.
I'm trying to find a range of cells by a criteria and the copy that range to another part of the sheet, The finding the data is ok i think, its just the copying... SpecialCells
Private Sub GetMainClass()
Dim Class As Range
Dim Cell As Range
Dim Destination As Range
Dim Counter As Integer
'searches entire sheet
Set Class = Selection.SpecialCells(xlConstants, xlTextValues)
' Initial setting of the counter. first row for data is the integer
Counter = 20
'set up the destination range with a counter to increment the row so data doesn't overwrite
Set Destination = Range(Cells(B, Counter), Cells(I, Counter))
For Each Cell In Class
If Cell.Value = "Main" Then
Cell.EntireRow.Copy Destination
Counter = Counter + 1
End If
Next Cell
Application.CutCopyMode = False
End Sub
I'm using a macro for searching through ~200k rows of a column, finding all the occurrences of a string and copying them to another column.
This is the code (copied from somewhere some time ago, modified as needed) :
[Code] .....
It works great but it takes a little less than 20 seconds to complete the task.
And, since I have to search for multiple strings and the results need to be copied to different rows, I use multiple subs like this in a bigger macro.
The problem is that it got to the point where it takes 3 minutes to execute that bigger macro and I'm trying to find a way to speed things up.
I have small problem to solve and I can't find out how: I have to find cells in a range (L4:L20) with value PM and copy range with two next cells to cell F4 (not a cell with "PM") If in range("L4:L20") cells = PM then copy range with next 2 cells to ("F4"). See attached worksheet.
View 3 Replies View RelatedI want to save myself some time at work, that's why I want to create an automatic sheet in Excel using VBA. I need to create files with monthly reports of data.
My project looks like this:
1. Gather information from user (Month & Year)
2. Create a file which name is based on Month & Year
3. Select data sheet
4. Find date range to copy (RowBegin, RowEnd)
5. Copy nad Paste required data into new file (point 2.)
6. Delete rows, formated in certain way
7. Find bottom of all columns and insert row with all formulas
8. Format all sheet acording to requirements
I was looking over MrExcel.com and I know how to do all the points besides point -> 4. Find date range to copy (RowBegin, RowEnd)
I got a column "D" with about 5000 cells for now and the sheet is updated daily. In those cells I got dates formatted like this:
D
4012 14/02/2006
4013 21/02/2006
4014 15/03/2006
4015 15/03/2006
4016 17/03/2006
4017 07/04/2006
4018 07/04/2006
4019 20/04/2006
What I don’t know is how get in VBA two variables – range of row numbers describing selected month (for example March) - from (RowBegin) & to (RowEnd), in this case RowBegin=4014 and RowEnd=4016, which I can later put into:
RowSub = RowEnd - RowBegin
Range("A”&RowBegin&”:A”&RowEnd).Copy Sheets("March").Range("A1:A”&RowSub)
I have some EXCEL files, titled as "AAA", "BBB", "CCC", so on... Calculated values are placed in Column Z for each file. In order for me to export the files to another software, I would need to create another new EXCEL file (I call it MASS) and place all the calculated values in that new file. In that new file, the titles have to be on Column A and the calculated values on Column B.
For example, File "AAA" has 120 calculated values. In MASS, the word "AAA" has to appear on Column A a number of 120 times and the 120 calculated values are then placed on Column B. Each value must correspond to the word "AAA". The same procedure goes for "BBB", in which the word "BBB" is placed on Column A after the end of "AAA". What I want to achieve is by using a macro that will look up the title of the Active Worksheet and then scan Column A in MASS. If the title matches whatever is in Column A, then the macro will paste the corresponding calculated values onto Column B automatically.
For example, for file "GGG", the macro will look up the word "GGG", scan through Column A in MASS for the start of the word "GGG" and paste the calculated values at the start of Column B. Could I have an idea of how might the macro looks like?
Hopefully someone can help me and understand what I am trying to do. I'm almost finished my project and stuck on one last part! If I have missed a similiar example on the forum could someone point me to it
I have a list of Lines (a,b...) which start at point i and end at point j.
Line i j Point x y
a 1 2 1 6 10
b 2 3 2 7 4
3 2 3
I have have a seperate list of the points. Each i point and j point have x and y coordinates.
I want to find the i point value in my list of points and copy the following two columns (the x and y values) to Sheet2. On sheet2 I want to paste the i values in row 1 and the j values in row 2, skip two lines and move onto Line b.
I am having trouble with the Find method in Excel VBA.
This is the piece of code that I have written:
Sub NCMVariables()
Dim x As Integer
Dim c As Object
Sheets("Data").Select
With Worksheets("Data"). Range("A1:A60000")
Set c = .Find("USD", LookIn:=xlValues)
If Not c Is Nothing Then
I have 10 worksheets. I would like to create a macro to find all the "2" values on worksheet 1, and have the actual range that the cell is, compiled into a list -example: I would like the list to be similar to this= (A1,B15 ,C8)
I even tried to record it but it doesnt show me the actual range that the data is found in.
I have data that is on a separate .txt file (the source file) that resembles this;
A
B
C
D
E
F
1
Case
District
Pct
Division
Level1
Level2
2
305035
0
20
72
[Code] ..........
Using VBA from within the destination workbook, I would like to use an input box that allows the user to request/specify what numerical number (0 through 55) in Column B of the txt file (the source file) will be used to determine what data to copy to the destination file. The cells to copy to the destination file would be from Column A through Column G of the source file onto Sheet1, E2 of the destination file.
Column B of the Source file will only contain numbers. However there will be numerous identical numbers in Column B. All of which will need to be copied onto the destination workbook.
From the sample above, if the user were to enter '15' in the input box, the desired result on the destination sheet beginning at E2 would look like this;
E
F
G
H
I
J
1
Case
District
Pct
Division
Level1
Level2
2
502046
15
1
3
[Code] ............
I've attached a workbook which contains two sheets:
PAYM
DEVICE_PAYM
Data is updated on DEVICE_PAYM each day with the figures I need located in column "AN". I need to be able to copy the data from "AN" and paste it into a column on the PAYM sheet. The destination column on the PAYM sheet needs to be specified by inputting a specific date - ideally, I would like to use the calendar Add-In as part of this process. I've already input some code for the calendar but am unable to develop this further so that it finds the correct date column and pastes the data across from the other sheet.
Am working in Excel 07, but this would need to work in 2000 as well.
Need a macro that will...
1. Select a range of cells from B4 to RX. X is defined as the last row where Column A has a value.
2. Copy the visible cells
3. Open an email in Outlook (not via the email workbook function of excel), enter "Submission" into the title, enter "Dear X," insert 2 returns.
4. Paste the copied table (not the workbook, just what is on the clipboard) into the body the email.
Let's imagine I have many informations about 'Domains' such as Emails, phones, etc. My lists are long and it happens very often that I have the same domain (row) many times. No way to remember each time if I already filled the informations for this specific domain before.
THat's why I want to know if there is a way that ALL the informaitons on the Row of : Domain A will automatically be copied to another row where it will find another Domain A
The Conditional formatting (highlight duplicates) do part of the job by telling me where are the duplicates, but i need the other infos to be copied.
I am looking for a macro to do the below
copy range b2:b8 from sheet 2
find the first empty cell on sheet 1 row 2
paste values into there
I have a list of data by daily date only for days when the market is open. I need to select the data for each Friday (if the market was not open that Friday then I need to take the Thursday’s data) and copy that data into new cells thereby creating a set of weekly data. The daily data is in columns A to F and in rows 2 to 1400. The Friday data of each week is to be copied to columns G to L and to rows 2 to 300. I need to have the data without row gaps as I use this data subsequently.
I have attached a sheet with some daily data. I have manually copied a sample of Friday data to the desired location in red to show the solution I am looking for. An additional problem is that I need to copy across a daily moving average, from column F to column L, and being a calculation from daily data it does not copy and paste.
I have a "data" workbook with various data in columns. Need to create "master" workbook that generates 3 different reports. Need "master" to contain macros that searches "data" and generates report based on search.
View 7 Replies View RelatedI am needing to find a specific row of data in one workbook and, once found, copy and paste the values into another workbook. The worksheets in both workbooks are formatted exactly the same. Only the first eight fields of the row need to be copied (e.g. A7:H7, A150:H150, etc.)
Will a combination of VLOOKUP and ROW do this and how do I get them to work together? Once the correct row is found, how are the fields selected, copied and pasted into the specific worksheet of the other workbook?
I want excel to copy some data fram 5 defined colums into the first empty row in a list. The problem is decribed better in the attached dummybook.
View 2 Replies View RelatedI need to firstly find data in the main sheet which relates to the activecell and then I want to copy and paste that data into another worksheet.
The simplest of ways I guess would be the .xldown function however this seems to copy the blank cells as well as the cells with data, which is no good. I have therefore written code as below which finds the first cell with data, copies and pastes, then loops.
How do I set the loop to look at the next cell down from the initial copied cell and if there is data in it to paste it into the cell underneath the one I have just pasted into?
Range("D3") = ActiveCell.Offset(0, 1)
SheetName = Range("D3")
ActiveCell.Offset(0, 2).Select
[Code]....
In table 1 you will see that not all rows contain data (this is because i have removed it previously with a macro) the second table shows what i want the macro to do but without deleting rows:
A
Hiddenrow with formula
B
C
[Code]....
So basically i would like a macro to search for the first none blank value in column A and copy the row to the first available blank row , it also needs to blank out that row once done. i.e row 3 would be moved up to row 2, 5 up to 3, 7 up to 4 etc etc.
The hidden rows contain formulas which cannot be deleted or my ws goes Pete Tongue.
Dim lCount As Long
Dim rFoundCell As Range
Dim sfind As String
Dim cl As Range
Set rFoundCell = Range("A1")
For lCount = 1 To WorksheetFunction. CountIf(Columns(1), TextBox1.Value)
Set rFoundCell = Columns(1). Find(What:=TextBox1.Value, After:=rFoundCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
With rFoundCell
End With
Next lCount.........................
this macro looks up in column A (a list of names) the name entered in textbox1 (of userform2). if found - the value is "copied" to E13. (if not - showes message - " does not exist") for example: it found the value "Dainna" (which was typied in textbox1) and copied it to E13. i want the macro to keep on to the next cell (in the row where Dainna's in- B3) and copy the age to F14.
I am needing to find a specific row of data in one workbook and, once found, copy and paste the values into another workbook. The worksheets in both workbooks are formatted exactly the same. Only the first eight fields of the row need to be copied (e.g. A7:H7, A150:H150, etc.)
Will a combination of VLOOKUP and ROW do this and how do I get them to work together? Once the correct row is found, how are the fields selected, copied and pasted into the specific worksheet of the other workbook?
i want user using userform to search for the wanted data then the displayed data be copy to another new sheet.. and be able to print!
hope the idea is clear!
i will attach the file in case someone wants to show me the example...
- I copy some records from a Database into an Excel sheet in workbook (say W1) in the Worksheet WS1.
- The i look up for values in a column (say column B) of W1 in another worksheet in another workbook(say W2) .
- If i find a match in Workbook 2(W2) ,Worksheet 1 , Row 2, Column A ; i look at the values in the Column B, F,G on the Row 2 itself.
- Each of these values can be found in the corresponding Worksheets 2;3;4 in the Workbook2(W2) .
- Then i need to pick up all these values from worksheet 1;2;3;4 in W2 and contatenate them and put them in the Workbook W1 against the Row .
- Similarly i process all the non zero rows in the workbook W1.
I've been trying to modify the following code to find the value "Module Index" in column A. I then need the code to save the row number that the value was found in and copy a range from ("A2:V row number")
I keep getting an "object required" error on the following code line
Set intFindrow = wbTargetBook.Sheets(strName).Range("A:A").Find(What:="Module Index", LookIn:=xlValues)
[Code] .....
I think I am closer but how do I get all of the data from A2 in the origination worksheet and then copy it to the last blank cell in column A in the destination sheet?
Code:
Sub test4()
Dim lastrow As Long
Set StartSheet = ActiveSheet
'MFG PART NUMBER
StartSheet.Range("R2").Copy
Workbooks.Open Filename:="D:\_DoxaMobiusServtrax Import Template"
[Code]...
I am going to explain the issue with a photo linked below
Capture2 | Flickr - Photo Sharing!
Basically i want to match data from column one with data from column 3 if true then copy the data in column 2 to columns 4 in the same match row.