VBA Copy And Paste On Multiple Ranges
Oct 28, 2011
I am trying to write a basic VBA code to effectively remove the formulas from a workbook to reduce the size. I want to save the formulas in one hidden row above the data and have the macro select this row, copy the formulas down to the data, calculate the sheet, and then copy and paste the new calculated info and paste as values
Issues making this more difficult:
1) The number of rows of data is not constant, therefore I believe I need to make vba count the rows of data and therefore know how many rows to paste
2) The formulas are not in every column (E.g. A:C, E:R, AA:AD have formulas)
Here is a basic example:
A B C D E
1 FORMULAS (Hidden)
2
3 [Inv. Typ] [Material #] [Batch] [Qty] [$]
4 [FG] [545] [555A] [5000] [$250000]
5 [WIP] [984] [659A] [200] [$650000]
In this example I would like the macro to:
1) Copy the hidden formulas in (A1:B1, D1:E1)
2) Paste these formulas into the range (A4:B5, D4:E5) (*The height of this range is not constant)
3) Calculate the Worksheet
4) Copy and paste values to the range (A4:B5, D4:E5) (*The height of this range is not constant)
* I would like column C to be left alone.
View 4 Replies
ADVERTISEMENT
Apr 21, 2013
I've got several worksheets that all have the exact same layout that a user will enter unique information in to each worksheet. Then I've got a final worksheet that I want to have a button that the user can click and when they do, it will look to each worksheet and do the exact same process for each worksheet as follows:
It first looks to see if the worksheet is visible. If it is, I want it to copy the range A5 to K5 down until it gets to the last non-blank cell in column C. The first non blank cell that will be referenced will be C7. Then I want it to paste this information into the range A5:K5 on the final sheet named Sheet8 with the same values and keep cell formatting such as width and height, font. If the worksheet is not visible, it skips the sheet.
I want it to do this for each visible worksheet, placing the next visible worksheet info under the previous visible worksheet info. My current code as shown doesn't do that. It requires that something be inSheet8 A6 before it will even paste, then it pastes the info from A5:K5 but it doesn't do just the values nor does it keep the formatting. What I mean about not doing just the values is some of the info that needs to be copied comes from a drop down they can choose from and it copies the actual drop down menu. Also, it seems to copy all of the ranges from each sheet and paste it into just A5:K5 on Sheet8 and overwrites each other instead of pasting Sheet2 just below the information from Sheet1. So the only information shown after the entire process is completed is the information from the last visible sheet.
If Worksheets("Sheet1").Visible = True Then
Sheets("Sheet1").Range(Sheets("Sheet1").Range("A5:K5"),
Sheets("Sheet1").Range("C7").End(xlDown)).Copy
Sheets("Sheet8").Range("A5").End(xlDown)
End If
[Code]...
View 4 Replies
View Related
Dec 7, 2008
I want to be able to prompt a user to select a sheet to import to another file. The ranges are as follows.
Sub Importtimesheet()...
View 9 Replies
View Related
Feb 19, 2009
In my consolidating spreadsheet there are 6 columns that show the file path, the worksheet name, and cell range to copy. There can be an unlimited number of rows (each row represents another path). I would like the VBA to copy/paste values from each range specified in each row and copy them into the consolidating worksheet named "copied".
Each time the VBA copies/paste values from the cell range specified in each row it needs to copy below the previous copied and pasted information in the worksheet named copied.
In the worksheet with the file paths etc shown below (named "list"), I would like the VBA to show the Date and Time each piece was copied and pasted. For each path I would like to show in the last column if the copy and paste operation was successful ("yes" or "no"), this is more or less the error handeling....
View 9 Replies
View Related
Dec 18, 2006
I'm trying to copy range from one worksheet to another. I'm guessing there must be something wrong with my syntax here:
For Count = 2 To 50
If Sheets("sheet1").Range("H" & (Count)) < 0.1 Then
Sheets("sheet3").Range("A" & (next_place), "K" & (next_place)) = Sheets("sheet1").Range("A" & (Count), "K" & (Count))
next_place = next_place + 1
End If
Next Count
View 4 Replies
View Related
Oct 5, 2006
I need a Excel VB Macro which copies specific ranges from all available Excel workbooks in a Folder and pastes the values in a target Excel workbook in different columns. In other words it would copy Cells F4-F15 from all excel files (say 20) in a folder and paste them in the target Excel file in 20 columns.
View 2 Replies
View Related
Apr 10, 2008
I am using Excel 2007. I have a worksheet called January and I have a range of formatted cells in 'January' between B15:18 and BA15:18. Some contain formulas, others are just formated to size and or color. I want to copy and paste this range of cells (B15:18:BA15:18) to the next available unformatted or blank cell of the column of the same worksheet by pressing a button. I also need the newly pasted range to reset to their original formatting assuming data was entered before the button was pressed.
View 5 Replies
View Related
May 16, 2014
I am trying to Copy Cell from one sheet to another sheet starting on A7 and then going to V ? i have a formula that figures that out for me just need another formula or VBA to copy it to the new sheet. i will attach the a test of the file.
View 3 Replies
View Related
Mar 18, 2014
I use to have a macro that could copy formulas from non contiguous ranges and paste the values in the same cells. So for example, I could select a non contiguous range like B5:B10, E10:F12, and G1:G10. The macro would then copy and paste the values in those 3 ranges, so those 3 ranges would be values instead of formulas.
I think it worked by storing each range and then looping through each range to copy and paste special values.
View 2 Replies
View Related
Dec 20, 2007
Been playing with this for some time and can't quite figure it out. I'm trying to copy a named range and paste special value to another named range of the same size. I recorded a Macro that does what I need, and I'll use if necessary, but thought I'd try to consolidate the code a bit and can't get it to work. The recorded macro is as follows:
Sub PasteRanges()
Application.Goto Reference:="DataCopy30Yr"
Selection.Copy
Application.Goto Reference:="DataPaste30Yr"
ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False, _
IconFileName:=False
End Sub
My attempt to consolidate was this:
Sub PasteRanges()
Range("DataCopy30Yr").Copy Destination: Range("DataPaste30Yr").PasteSpecial (xlPasteValues)
End Sub
I get the Run-time error 1004 Copy method of Range class failed when I try to run this. Again, I can use the longer version with no problem, but in the interest of learning and since I have spent some time not being able to come up with the solution, I thought I'd ask the experts opinions before I gave up on it.
View 6 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
Aug 27, 2006
I have this
Sub transpose_UPCID()
Application.CutCopyMode = False
Range("A7:B7").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("BAUCS").Range("C11").PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Application.CutCopyMode = True
End Sub
This macro copies a range and paste it in another worksheet. I dont now how to make this macro to copy another range at the same time and copy it to row C37.
How can I make both things at the same time? The code I am showing here copies and paste product codes. I need to select and copy the production (which is in column F) for each product code and paste it starting in C37.
View 3 Replies
View Related
Feb 27, 2008
Is there anyway to simplify multiple copy and paste from one workbook to another when there are multiple and different size of data to copy. this is what i have done below. It was a bit tiedious writing it all out
Workbooks("AVA_DA_140906_BPL_SSE_001.csv").Worksheets("AVA_DA_140906_BPL_SSE_001").Activate
Range("E3:G110").Copy
Workbooks("DailyAvailability.xls").Worksheets("Availability").Activate
Range("E17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Workbooks("AVA_DA_140906_BPL_SSE_001.csv").Worksheets("AVA_DA_140906_BPL_SSE_001").Activate
Range("C3: C110").Copy
Workbooks("DailyAvailability.xls").Worksheets("Availability").Activate
Range("H17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ ...
View 4 Replies
View Related
Nov 7, 2009
I have 8 different files all have a set of data in them
each one has a long list of (column a-n) however the number of rows change by date. I need each file copied into the finalfile.xls one after another. in the files that will be merged into the final file the final row i need copied is blank.
I have all the copy formulas and everything set, I just need a range to copy that automaticaly takes cell a10 to the first blank a cell from each file and pastes it in the finalfile.xls under the last paste so they dont over write each other.
View 9 Replies
View Related
May 8, 2008
I need to copy multiple cells from 1 worksheet to another worksheet on different workbook and for every entry it has to create a sequence #
- source file (ex. data1.xls, data2.xls, etc)
* data & field structure is fixed
- destination file (case1.xls)
* field structure is fixed
1) destination file (case1) will be opened first, a button is prepared (associated w/ macro) and it will open the source file (ex data1.xls) & then copy the cells B2,B3 and E2,E3
2) the copied cells will be pasted to destination file (case1) in cells B3,C3 and D3,E3 respectively
3) a sequence # will be created in cell A of the destination file
this process will be repeated to other remaining files (ex. data2.xls same structure as data1.xls) manually. It means i will perform the task only if required. i have a created a simple code attached to case1.xls
View 6 Replies
View Related
Jun 10, 2009
I have a file for monthly result of different staffs (over 1000 of them) shown in Col A. Their monthly result are obtained by Vlookup, then copy and pasted in Col B. The staffs are arranged in groups, and each of those groups usually no more then 10 persons. What I usually do is the follow steps:
(1) Input the Vlookup in, say for Feb, C1, then drag the corner of the cell and pull down as copying the formula to the bottom cell (this will create errors in the S Total rows (row 8, 13, 19 etc) but will overcome later).
(2) Select the entire Col C, then copy and paste value, to make all the data into a value.
(3) Select the S Total cell from the previous month (B8, B13, B19 etc), drag the corner of the cell, and pull to the respective S Total cell in current month (C8, C13, C19 etc). This will copy the sum of each group formula from previous month column to the current month column. And also it can clear out the errors generated by step (1) above.
Due to the size of the staffs, I have over 300 repetitions of doing step (3). It is so time
consuming, and I feel like an idiot. As you know, Excel 2003 does not allow multiple copy and paste. I have tried grouping the staffs, hide details, then do the copy and paste but unsuccessful because it will be multiple and paste as well. I cannot change the format of the table because many others will use this table too.
View 10 Replies
View Related
Jul 12, 2013
I have created a named range that selects about 30 different cells (non-contiguous) and I am trying to copy over all the formulas and paste with values. However excel is not letting me to do this. It says this command cannot be applied to multiple selections. Can I get around this?
View 3 Replies
View Related
May 28, 2005
I want to copy a selection of cells and paste them into a row on another
sheet.
An example would be to copy:
Sheets("Sheet1").Range("T5,C7:T9,T13,C15:T17,T19,C21:T23")
and put it into A4:F4 on Sheet2
I know I can do it one cell at a time but I was hoping that I could speed
things up and do it all in one go as the macro will be quite long.
View 9 Replies
View Related
Jun 6, 2014
I would like to create a formula on sheet 1 and be able to copy and paste it to 20 sheets in the same workbook.
View 2 Replies
View Related
Jul 28, 2007
I want to copy several separate sections on a worksheet and place these sequentially in an array, then paste these in order into another worksheet.
I have written a macro to copy and paste between the two spreadsheets, however, this is rather basic as it involves straddling between the two and performing multiple alternate copy and paste operations, as only one section can be copied at any one time.
View 9 Replies
View Related
Jun 18, 2009
I am importing some text files into an excel worksheet. I want to change the format just a little bit. For each date I have 5 rows (pixel: 25, 37, 50, 100, and 200). When I import my data the date is in the same row as my pixel numbers. I want to place the date in another column to the left of these pixel numbers.
Below is an example of my "spreadsheet" The first 5 lines (with date "2008_308.txt" next to each pixel number is what I want it to look like and the next (with date "2008_309.txt" is how it is imported with only one date above the pixel numbers. I could do this manually, but I have many years of data to import. And would like a way to kind of copy/paste these multiple items at the same time. Any ideas? .......
View 9 Replies
View Related
Sep 1, 2006
I've coded wrong. I get "Run-time error 424: Object required" when I run it.
Dim ws As Worksheet
x = 0
For Each ws In Worksheets
Select Case UCase(wSheet. Name)
Case "SAMPLE RESOLVED", "RESCALLTYPE", "DATA", "SUMMARY"
'Do nothing
Case Else
ws.Range("J22").Copy Destination:=Sheets("Summary").Range("B2").Offset(x, 0)
ws.Range("C3").Copy Destination:=Sheets("Summary").Range("A2").Offset(x, 0)
x = x + 1
End Select
Next ws
View 3 Replies
View Related
Feb 6, 2007
i am trying to create an invoice with the data from one sheet(invoice list1)to copy this and populate an invoice that i have in another workbook(invoice)
i need to generate for however many lines there is in the invoice list the equivalent number of invoices.
ie the data in list will be copied to relevant cells in invoice so
cell A4, A5 FROM (INVOICE LIST1) will go to cell B10, C10 of ("invoice" workbook)
cell E4 and f4 go FROM (INVOICE LIST1) go to cell b11,b12 ("invoice" workbook)
and cell g4(invoivelist1) will go to d12 of "invoivce"
i will attach the workbooks
View 3 Replies
View Related
Mar 29, 2008
I need to copy from AS400 (ISearies) to Excel, return to AS400 and repeate a number of times for a specific AS400 layout. (Example) I would copy for AS400 row 7, column 2 thru row 7 column 10 then paste to Excel A1, repeate for row 8, column 5 thru row 8 column 15 and paste to A2, ETC. I need to keep repeting this about 20 times. I have a group of employees who do this all day. A Macro would speed work.
View 2 Replies
View Related
Oct 12, 2011
I have a workbook with 6 worksheets in, 5 worksheets contain data whilst the 6th I will use as a search worksheet. The 5 data worksheets contain columns A to J which have text entries in.
What I would like to click a button on the search worksheet, lets call it worksheet 1, and for an inputbox to allow the user to enter a text search. The macro would then search for this text in columns A to J and all rows (or rows with data in) on the 5 data worksheets, and if found, copy the entire contents of those rows where the text is found and paste them into worksheet 1, the search sheet.
I have done a forum search and found a few examples of this type of search but not across multiple worksheets, also I found this code that does search across multiple sheets but does not copy and paste:
VB:
Sub Find_Data()
Dim datatoFind
Dim sheetCount As Integer
Dim counter As Integer
[Code]....
View 5 Replies
View Related
Mar 20, 2009
Basically on the file below whenever there is data in column "type" I want excel to copy the "name" and "account" next to it. The whole file has about 80,000 rows. Spacing is not always one blank row between accounts. I am using excel 2007.
View 5 Replies
View Related
Jan 10, 2009
How can I copy a column (C6:C200) and paste it according to a cell value . If I have in a cell 5 it will paste column (C6:C200) five times .
View 7 Replies
View Related
Mar 26, 2009
I have the following VBA code in Excel that looks in sheet called mri.txt for a cell called “AcquisitionMatrix”, Then goes one cell down and two cell to left and copy them all into Application.Workbooks(imgMain).Worksheets("Sheet1").Activate cell “AC2”, But for some reason it copies the field’s name as well such as:
AcquisitionMatrix , 0, , 256, , 256,.
Is there a way to avoid copying the filed name into cell AC2? Such as :
0, , 256, , 256,?
here is the
View 2 Replies
View Related
May 12, 2009
I have a spreadsheet that contains data that is currently split up into 2 or more cells. Sometimes it's 2 cells, sometimes 3, even 4, etc. I would like to right click on multiple adjacent cells, select copy, right click on another cell and paste these multiple cells into 1 cell. I checked paste special but didn't really find anything. I'm not sure a formula/macro would work either as I need to manually determine which cells need this attention.
View 2 Replies
View Related
Jul 9, 2009
Thank you all so much for this wonderful forum. Today has been a day of going through post after post. I am usually able to solve my problems through reading similar issues. However, just can quite get this one and I think it is rather simple, but frustrating none the less.
Attached is a spreadsheet with a list names in column B. The codes I have tried to write or have copied find one name and paste it to sheet 1. However, I need to find several names and then copy each row to sheet 1.
View 14 Replies
View Related