Editting Macro To Select Last Empty Column To Paste Data
Nov 30, 2008
I have a macro that automatically takes data from one sheet, copies it and pastes it on another sheet, but I want it to select the empty column that is to the right of the last column to contain data (so basically the next empty column). What code would I enter into editting my macro to be able to do this please?
Also, one thing I've tried to do with my macro is that when I select the data, it's suppose to select from the first name to the last. When doing the actions for the macro, I use "Ctrl + Shift + Down Arrow Key" to make the selection select the bottom of the list. However, when running the macro, if the list is longer (or shorter), the macro selects that number of cells instead of the action of just going to the bottom of the list. For example, if during the actions of the macro, I recorded using the Ctrl + Shift + Down Arrow Key that 50 cells were selected...next time if I have 60 cells, only 50 are selected, even though I used an action command which should select all the cells in that group (in this case being 60). Is there some code I can add to that so this would work correctly?
In case its required, here is the code from the macro:
View 11 Replies
ADVERTISEMENT
Mar 25, 2013
I am trying to find a macro that look for last non empty cell in column A and them paste a formula/comment in all cells of column B.
View 3 Replies
View Related
Apr 27, 2009
I have rather large Excel file that spans around 245 columns & has multiple users responsible for certain columns. Columns are chunked to provide data about a specific group. Every 72 hours, I need to provide to managers what’s currently on this file in a specific summary format.
I’ve recorded a macro that gets me half way there. Here’s where I’m clueless. After my macro deletes unnecessary columns, what remains are the columns for “Main Data” group + each of the 5 “Business” groups (Investors, Lawyers, Credit, Finance, and Support) which would have identical column headings.
(1) Name (2) Address (3) ID# (4) Control#
Furthermore, for each of the 5 “Business” groups, there are 9 slots (ie- a user can enter up to 9 unique entries for a particular group.)
Example- The Investor group contains 9 slots. Each slot will contain the 4 columns mentioned above. So there are 46 slots in total – 1 for Main Data, 45 (5 groups x 9 slots) for Business groups.
MAIN DATA (columns A-D)
Investor1 (columns E-H)… Investor2 (columns I-L)… Investor9 (columns AK-AN)
Lawyer1… Lawyer9
Compliance1… Compliance9
Finance1… Finance9
Support1… Support9
MY PROBLEM: I need a macro to now cut & paste all data from each of the 45 Business groups slots & then paste at the bottom of the MAIN DATA slot.
The final file would be 4 columns (as listed above) wide. Data from each of the 45 business group slots would be one below the other- all of it underneath the data in the Main Data group.
I attempted to record a macro where I’m copying a section’s data range starting from row2 to row4000 (I know there will never be 4000 entries. I did this just to ensure that all future data would be captured) then pasting that after the last entry in the Main Data.
Example- I’d copy data from Investor1 slot(starting at column E2-H2) & go about 4000 rows down. Then I’d press CTRL+Down Arrow key in column A & then click the down arrow one time to take me into 1st empty cell where I would paste my copied data. I was going to repeat this process for the remaining 44 slots.
I’ve added some extra entries to test the macro & the problem is that the recorded macro is pasting data in specific cell location in column A instead for looking for the 1st empty cell in column A & then pasting the copied data.
So far I've gone thought the net & tried to paste in a few VBA posts/tips that I thought would work. Here's what I have so far from tinkering around. I need someone to tell me what to replace the xxxxxxx line with. This would be the language to tell Excel to paste copied data range into the first blank cell in column A. I've gone thought the net & tried to paste in a few VBA posts/tips that I thought would work.
Here's what I have so far from tinkering around. I need someone to tell me what to replace the xxxxxxx line with. This would be the language to tell Excel to paste copied data range into the first blank cell in column A.
Sub transposedata()
Sheets("ConsolidatedYTDReport").Select
Range("E2:H4202").Select
Selection.Copy
XXXXXXXXXXXX
ActiveSheet.Paste
End Sub
View 10 Replies
View Related
Nov 27, 2007
i need a method to find the end value in a row (right side) and select the empty cell to its right to paste data in.
problem is the row where this data is may change so using
limit = (row, col).end(XlRight).Col
View 9 Replies
View Related
Dec 29, 2009
Copy and paste data if row in Column N is empty.
Here is my current code
View 2 Replies
View Related
Dec 13, 2013
I want to create a macro to paste some data into the next empty cell. Below is sort of what I need but this show it going to a particular cell, I need it to got to next open cell in the range from say BY3. So next macro run it would copy and paste the data from T3:T9 (always this range) to BZ3 then CA3, CB3 and so on.
[[Sub CopyData()]
'
' CopyData Macro
' Copy The Data To Build Graph
'
[Code]....
View 1 Replies
View Related
Mar 15, 2013
I am looking to create a macro to be assigned to a button that copies the last row of data entered and then pastes it to the last empty row on a different worksheet. This is a dummy spreadsheet to work with (I have more data, but the concept is one in the same). Sheet1 ("Branch1"), Sheet2 ("Branch2"), and Sheet3 ("All"), the names in brackets are names of the sheets, but for ease I'll refer to them as Sheet1, Sheet2, and Sheet3. I have columns beginning in B as follows: Date, Branch, Currency, Coin, and Total (the branch and Total are tied to formulas, however I just need to the text values and formats to come over to the other worksheet). have the portion regarding the copy of the last row in Sheet1, however it won't PasteSpecial.Selection in Sheet3 as it says the cells are not sized or formatted correctly.
VB:
Sub CopyB2()
lr2 = Sheets("Branch2").Range("B" & Rows.Count).End(xlUp).Row
lr3 = Sheets("All").Range("B" & Rows.Count).End(xlUp).Row + 1
Sheets("Branch2").Range("B" & lr2).EntireRow.Copy Sheets("All").Range("B" & lr3)
End Sub
View 1 Replies
View Related
May 8, 2014
I'm never done a macro before and of course I'm very new to excel. I have a worksheet for lessons learned that have multiple sheets for each state. I want to create a macro that every time I enter a new data into a row and hit "Add to summary sheet" and it copy and paste the the next available row in summary sheet.
See the attached file for my workbook : Book1.xlsx‎
View 9 Replies
View Related
Jul 30, 2013
Is this possible using code: Copy Cell A1 and Paste in first empty Cell down Column D. This would be connected to a command button. Both Cell A1 and Column D are on the same spreadsheet.
View 3 Replies
View Related
May 28, 2007
How do I code in VBA - I need to select the next empty cell down in a column - ie blank field so that I can transfer the next set of data
View 9 Replies
View Related
Feb 5, 2007
create a code such that it will select a cell which is not empty and display the content in that cell. For example , in the attached file below i would expect output to be cells(2,5) = 12 and cells(4,5) = 13
View 2 Replies
View Related
Jun 20, 2006
how i can go about finding the next empty row (and select the first cell of that row (column A))? edit: It probably should be noted that there are cells in Columns A through P. There are rows where all and/or just one cell contains data per row. So i cannot use a " lookup" based on a single column.
View 2 Replies
View Related
Feb 27, 2008
I am trying to paste data into a sheet immediately following the last weeks data. I went to use an offset function like :
Range("A2").End(xlDown).Select
ActiveCell.Offset(1, 0).Select
However, each weeks data is "Grouped" and therefore the .end(xldown) only takes me to the bottom of the visible rows, and the offset function selects one of the hidden cells.
View 5 Replies
View Related
May 12, 2014
Macro below - it now works and selects all the data in spreadsheet and converts to Proper Case
However I also need a macro to select all except the last column of data and convert all except the last column to Proper Case
It is for Post / Zip code info. so wish to keep it in Upper Case.
What I have already is:
Code:
Sub Propercase()
Dim LastRow As Long, LastColumn As Long
LastRow = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LastColumn = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
Dim r As Range, c As Range
Set r = Range("A1").Resize(LastRow, LastColumn)
[Code] .....
I was hoping I could easily amend the above to select all except last column.
View 3 Replies
View Related
Oct 1, 2013
Right now I use Range() to define where I want something pasted. How do I use get away from that to just use the next empty row, so I don't have to keep changing the code everytime the data sheet expands?
Here is an example of what I'm using:
Sheets("Sheet1").Select
Range(Range("F4"), Range("F4").End(xlDown)).Select
Selection.Copy
Range("BX4").Select
ActiveSheet.Paste
Range("BX3").Select
ActiveCell.FormulaR1C1 = "Header"
View 9 Replies
View Related
Dec 9, 2011
I need the code to paste my selection in worksheet SORT, into the first available cell in column A. Intention is not to overwrite existing values in column A.
'
Sheets("tis").Select
Range("AC2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("SORT").Select
'I need the code to paste my selection in the first available empty cell in column A, so I don't overwrite any existing values in column A
End Sub
View 2 Replies
View Related
Jun 9, 2007
Need code to copy a column from a worksheet, and paste it in the first empty column in a second worksheet? I can do this easily when I want to copy/paste to the first empty row using the
Sheet3.Select
Range("A1:A10").Select
Application.CutCopyMode = False
Selection.Copy
Sheet2.Select
Dim LastCell As Range
With ActiveSheet
Set LastCell = .Cells(.Rows.Count, "A").End(xlUp)
If IsEmpty(LastCell) Then
'do nothing
Else
Set LastCell = LastCell.Offset(1, 0)
LastCell.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End With
but I cannot find a way to change this to columns!
View 7 Replies
View Related
Aug 23, 2007
I need my macro to copy and paste from one worksheet to another, which is fine. However I need the copied value to be pasted into the last empty cell in a specific column. It is currently pasting each copied value into the last empty cell in column 'A' regardless of which column I specify it to copy to in my code.
View 5 Replies
View Related
Jul 25, 2014
I have 2 worksheets, one called "Consolidated" and one called "Converted".
I have a spreadsheet where I press the update button and a macro runs that searches for the word "Converted" in column E on the Consolidated spreadsheet (the original). When it finds it, the entire row will be cut and pasted onto the "Converted" worksheet.
I have managed to do this with my current code. However when you press the update button again, all the newly pasted rows on the Converted worksheet are deleted. (I would like when i press the update button it to NOT affect the Converted worksheet, just add any new data found on the Consolidated sheet to the Converted sheet.) I assume this is because my current code her below is NOT telling the spreadsheet to paste to the NEXT AVAILABLE EMPTY ROW. Current code:
[Code].....
So the problem is this line:
[Code] .....
I have attempted to replace this line with:
[Code] .....
But there is something wrong as the code keeps breaking on that line!
View 5 Replies
View Related
Nov 27, 2008
I would like a macro that will select the 65536th row to be used to paste format from rows 2 to the last empty cell in column a.
View 5 Replies
View Related
Feb 21, 2014
I have this macro and at the present time, can only compare two worksheets. One of my worksheets contains column headers with data, the other worksheet just contains column headers. The macro will match the data against the column header and paste below. I'm doing it this way because I have several tables I export from a MySQL database, but some of them have more fields than others so I was trying to get all of the data to line up in under the correct column header from each table. I need editing the macro to allow for
1) More than one worksheet to be analyzed at a time
2) If the first request is not possible, I would like for the macro to paste results at the next empty cell. As of now, it will only copy one at a time (which requires me to house the data in another worksheet everytime I run the macro).
Below is the code:
Dim ws1 As Worksheet, ws2 As Worksheet
Dim HeaderCells As Range, Hdr As Range, hdrFIND As Range
Application.ScreenUpdating = False 'speed things up
Set ws1 = ThisWorkbook.Worksheets("HEADERS") 'Define name of worksheets
Set ws2 = ThisWorkbook.Worksheets("B")
[Code] .......
View 1 Replies
View Related
Jun 25, 2014
I need to create a data base from figures extract everyday. I would like according the date to copy the figures in the sheet "Extractor" to paste in the column corresponding to the day of today in the sheet "Database". If possible as well, the figures of the dates before today must be delete (in the color tab)
I join a sample of what I have. I tried with the indirect function, but didn't find how to keep the figures of the previous dates.
View 2 Replies
View Related
Apr 12, 2007
how does one go about finding a specific valuein a worksheet, then selecting the value in the next column, then pasting the value in a different worksheet?
For example, I want to find a particular person's name in a worksheet, upon finding the name, I want to select the number associated with the person which is in the column to the left of the name. I then want to copy and paste the number in a different worksheet.
View 4 Replies
View Related
Mar 24, 2014
in creating a Macro which copy and paste the data from "Sample2.xlsx" file to "Sample.xlsx" file after row count in each column. Macro should not overwrite any previous data present in workbook.
Note: Sample2 workbook is containing a Variable Columns. Macro should match the headings of the Column in both workbooks and then copy and paste the data after row count.
View 4 Replies
View Related
May 30, 2012
I have the following macro that imports a copy of data into a worksheet. I would like it to paste the data below in first empty row (where column A is empty) instead of A1. I am using Excel 2010.
Sub Update ()
' Import_New_data
'
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
[Code]....
View 2 Replies
View Related
Nov 18, 2013
I have a workbook with four tabs or four sheets.
Tabs 1, 2 and 3 have a column of data (Column A) on each sheet. They all start from the same cell. Each cell of data are just numbers. The column (an array) of data will not have blanks between.
But, they are not the same number of data. They vary.
Meaning, Tab 1 may have 15 numbers (A1 to A15), Tab 2 may have 20 numbers (A1 to A20) and Tab 3 could have 5 numbers (A1 to A5). Each iteration of the workbook may have different number of data in the A column on these tabs.
Now on Tab 4, I want combine the data from all three tabs into one column (in column A).
So, Tab 4 has a column A with data from Tab 1 copy and pasted to (A1 to A15) as values, then (A16 to A35) have Tab 2 data copy pasted as values and (A36 to A40) have Tab 3 data copy pasted as values.
Basically, the macro on Tab 4 has to count the number of rows on each Tab that are populated with data values and figure out to copy all the data on Column A from each three tabs and paste the data value into the Tab 4 in one column of data (in values).
View 6 Replies
View Related
Nov 15, 2008
I am making a worksheet that I intend to use to track my money. When I first open the worksheet, it opens on a tab where I can click a button to report a type of transaction. For example, if I make a withdrawl from the bank for $50, I click the button, it takes me to the sheet that tracks my bank-related stuff, selects a cell and opens up a form, at which point I type in what the transaction consisted of. However, the sheet also tracks what is in my wallet, so I'd like to finish reporting the bank transaction in the form, and have a button to click that reports the wallet part automatically.
So, essentially what I need to do is select several non-contiguous cells that are in the last row of the bank sheet, copy them, switch to the wallet-tracking sheet, and paste them in a row that is one past the last row of that sheet. The paste should keep the cells next to each other, even if they were non-contiguous when they were being copied.
View 10 Replies
View Related
Jan 20, 2009
I am trying to find a macro that will filter on Column F (non-blanks - just cells with dates) cut just the filtered data (A:G inclusive)without the Header Rows and then paste/move this data to the first empty row on another sheet called "Complete"
So that I get the cells in columns A:G with dates in moved to the "Complete" tab and they are no longer in the sheet "Deliverables"
View 3 Replies
View Related
Mar 24, 2007
I am trying to write a macro to do the following: Loop through a range of cells on a worksheet Sheet1 M17:M46 and if there is text in the cell then Copy all the data to the left Of Coumun M in the same row and paste the values to the next open row of a range A17:L46 on another worksheet (sheet2.) Basically the text in column M is an idicator to add the data to an order sheet. If there is no text don't add the data , look in the next row etc.
I'm not sure if this is the way to go
Sub CopyRows()
Worksheets("sheet1").Select
FinalRow = Range("M65536").End(xlUp).Row
' Find the last row of data
' Loop through each row
For x = 2 To FinalRow
' Decide if to copy based on column M
ThisValue = Range("M" & x).Value
' could be any value
If ThisValue = "yes" Then
Worksheets("sheet2").Range("A" & x & ":L" & x).Copy
Worksheets("sheet1").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
ActiveSheet.PasteSpecial = xlValues
Worksheets("sheet1").Select
End If
Next x
End Sub
View 4 Replies
View Related
Jul 7, 2009
I'm using excel 2003. I would like to select and copy rows of data within a worksheet of a workbook and then paste those rows into a newly created excel workbook. That is the easy part. The complication is that I would like the macro to select the rows based on a particular string value that will be impossible to specify in a fixed way (i.e., it will change from project to project). Let's say the variable that distinguishes the rows is location, so some are from Tokyo, some New York, and some from Paris. Using vba, how can one 'splice' the data into (in this case, three) seperate workbooks based on the string/values of another variable?
I am familiar with auto-filter, but in this case, I really do need to create seperate workbooks, rather than apply calculations to a selection of the data.
View 9 Replies
View Related