Copy/paste To New Workbook Several Times....
Jun 15, 2009
I'm trying to create an "export" feature where certain data can be copied out to a new workbook. I want to copy out the following from the current workbook to a new one: Sheets("1TR").Range("C33:M999") to range("A1") in the new workbook
and Sheets("1PL").Range("K33:K999") to range ("L1") in the new workbook.
The problem I'm having is that it is not just one copy/paste exercise, but two, and I don't know how to reference the new workbook as it doesn't have a filename.
View 4 Replies
ADVERTISEMENT
Nov 18, 2009
I've attached below a small part of my code. I am wondering if there is a way to do this, without copying and pasting something 30 times, but using a loop instead. As you can see there are a series of productsNumbers (30 in total, but this example is for 3). Each productNumber is a string that is actually a 5 digit number, so it can be an integer as well, if it has to.
I would like to code below to loop for as many products as there may be. The way that I have it right now does not work - I feel that I am missing something small or that there is no way to do this.
View 3 Replies
View Related
Jul 31, 2012
I have a range A3:E70 where A3:E69 have the same formatting and the text in A70:E70 is bold. I want to copy-paste the entire range a number of times with a for ... next-loop. Actually, it's kind of a template system. I make the template A3:E70 and uses it a number of times.
View 2 Replies
View Related
Jan 4, 2007
I have an excel sheet, Data's range is B2:B5.
The data is listed as follows: Tom, Pete, Steve, Lisa.
I need a VB code to copy and paste the names (range) to J2:J17. By having the names pasted four times each.
The result would look like this:
Tom
Tom
Tom
Tom
Pete
Pete
Pete
Pete
Etc.
View 9 Replies
View Related
May 7, 2008
I have a task which I am sure can be done quite simply. I have a list of names in column A and a number in column B. I want a Macro to copy the name in column c, d, e etc for the number in column b.
View 9 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
Mar 14, 2014
I have the price of S&P 500 in the L2 until L145 column.
And I would like to past each cell (L2, then L3, then L4....until L145) 220 times in column F.
As follow
L :
1780
1715
1680
.........(144 value)
TO column F
F:
1780
1780
1780
.........(220times)
1715
1715
1715
.........(220times)
1680
1680
1680
........(220times)
View 6 Replies
View Related
Oct 9, 2007
I have a range of cells that is 10 rows high. I want to copy and paste this range 11 times while identifying each of the 11 copies of the range, such as; 02,03,04...12.
Please see attachment for an example of what I am trying to do.
Does anyone have an idea of how this might be done in VB?
View 3 Replies
View Related
Sep 30, 2013
I have a rand () which provides me a different number upon calculate. I would like to run a loop for 1000 times and take the value and copy and paste in a range.
The below sorta works, but at times it stops or doesn't work at all. I have a loop for the counter and the for each to place the value into the cell and have it run over and over and placing the value in the next cell underneath. I have the counter at 10 so I dont get stuck in some endless loop before I know it works.
Code:
Sub montecarlos()
Dim MCs As Long
Dim c As Range
Dim lCount As Long
Dim lNum As Long
lCount = 0
lNum = 1
Worksheets("MonteCarlo").Activate
[code].....
View 6 Replies
View Related
Jul 22, 2007
I enter a part number in "D1". The number of components required for that part number is returned in "G1" based on a VLookup. I would like a macro that will copy and paste the part number I enter in "D1" in the first empty cell in column "D" and will paste it once for each component (G1) required. For example, if the number of components required is 4, and the first empty cell in column "D" is "D10", I would like to paste the part number in cells "D10", "D11", "D12", and "D13".
View 2 Replies
View Related
Oct 12, 2007
Code copies the first two columns of a many column table and pastes them at a certain interval (14 columns) to make transfer to a report easy. The problem is that the worksheets each have a different number of columns, but none more than 56 columns. The macro works wonders on the first sheet, but thereafter does not work at all. The first sheet has 27 columns, the second sheet only has 4 columns and the one after has 38 or something.
Option Explicit
Public iMaleGroup As Integer
Public iFemaleGroup As Integer
Public iMaleAnimal As Integer
Public iFemaleAnimal As Integer
Public iMaleGroup1 As Integer
Public iFemaleGroup1 As Integer
Public StudyTitle As String
Public SmallAnimal As Boolean
Sub CommandModule()
Dim Wrkst As Worksheet
Dim wsName As String
Dim wsSubject As String
Dim wsNumber As String
Dim rSummaryHeader As Range
Dim MergedHeader
Dim NextMergedHeader
Dim HeaderRange
Dim AddHeader
Dim TableHeader
Dim SumTableHeader
Dim PasteRange
Dim x As Integer
Dim n As Integer
Dim z As Integer
Dim i As Integer
Application.Calculation = xlCalculationManual
Application. ScreenUpdating = False ............................
View 9 Replies
View Related
Feb 3, 2012
This macro works fine on my machine but not with other users:
This should copy/paste certain cells then paste 3 sheets into a new work book.
ON other computers it seems to paste in a picture? works OK for me?
Sub ValidationTests()
'
' ValidationTests Macro
' Macro recorded 21/12/2011 by '
'
Sheets("Score Sheet").Select
Range("A8:M18").Select
Range("H18").Activate
Selection.Copy
[Code] ..........
View 1 Replies
View Related
Dec 4, 2009
Just curios if this is the most efficient way to copy a workbook x number of times.
I tried copying 77 workbooks and not sure exactly how long it took, but about 2 mintues. The original workbook is 300 KB.
View 7 Replies
View Related
Mar 26, 2012
Copy data from workbook, open existing workbook, select range and paste. But my copied data is lost.
Sub Select_Copy_Paste()
'
'
Windows("ElektroFunctiesDatabase.xlsm").Activate
Sheets("PowerSupply's").Select
Range("A2:I6").Select
Selection.Copy
[Code] .........
' Here i need to do something to paste data into r.address?
View 4 Replies
View Related
Apr 24, 2009
I've been doing various searches for past few hours and can't seem to find out if one its even possible, the closet I've found on here is to copy row to another workbook.
My question is I have one excel book called level1.xls and another excel book level2.xls, now in level1.xls I have a row of fields filled in and in level2.xls I have a blank form which for example I would like to try programme in VBA from the level2.xls file to click a button and open automatically level1.xls then grab field "A2" value from level1.xls and place it in level2.xls field "L4" then continue using level1.xls "B2" to level2.xls in field "C3" and then continue down when I add more values A3, A4 so on in level1.xls to the same field in level2.xls L4.
Steve.
View 7 Replies
View Related
Jan 27, 2009
How can i copy paste a set of data from a workbook to another workbook. for example i will copy cell D10:I10 of workbook1 to cell B2:F2 of workbook2.
View 9 Replies
View Related
Oct 15, 2008
I have to gather a LOT of information from different files, into 1. To do so I want to automate this.
1. I will make a new, target file
2. I want to have a file with the macro in it
3. i want to open a (various) number of files to copy the info from
Now for my questions:
* How can I determine which other files are open (apart from the new and macro file)?
* How can I access each individual file, copy the information, paste it in the target file and close the "copy-file" after this
* Within the previous *): how can I determine how many worksheets there are in each file and do the copying sheets by sheet?
View 11 Replies
View Related
Oct 29, 2008
Need code that would copy range "A1:J1" to another workbook in the next available blank row.
View 9 Replies
View Related
Aug 2, 2006
Im trying to copy from one notebook to another and paste but to not paste over the information thats already there. I need to just paste my new info below whats already there. I have attempted this by filtering when I copy but its not working. My attempt is below. Right now Im filtering by column a but i need to be filtering by column c in the future.
ertyMerge()
ActiveSheet.Select
Range("a2:t65000").Select
Selection.Copy
Windows("Disc Pivots Template.xls").Activate
Sheets("Sheet1").Activate
Range("a1").Select
ActiveSheet.Paste
Sheets("Sheet1").Activate
Range("a1:t65000").Select
Selection.Copy.........................
View 6 Replies
View Related
Apr 6, 2013
I have created a spreadsheet some time ago and have been asked to improve on it but I'm rusty with VBA.
I have an automated ordering system that saves each sent order as the date e.g "05-04-2013.xls" but the management team want a graph with the data for the last 4 weeks compared. I have created a seperate workbook called "consumables report.xls" which has a column with the products listed followed by columns "Quantity" and "cost" which is repeated for the 4 weeks of the month.
I want to add a button to prompt the user to choose the saved order e.g "05-04-2013.xls" (all orders saved in same directory) to copy and paste the quantity and cost columns (c8,D69) into "consumables report.xls". I got this to work earlier but it would only paste the formulas and not the values. So I need
A prompt to open workbook
Copy range (c8,d69)
Close work sheet
Paste special .value (c8,D69)
I dont care if it has to open the workbook to copy the data as this will only be used once a month so it dosnt matter how slow the code is.
week 1 week 2 week 3 week 4
Product
quantity
cost
quantity
cost
cost
quantity
cost
1
2
3
4
5
6
7
8
View 7 Replies
View Related
Mar 26, 2014
For example i have workbook1,2&3, i want to copy the sheet(grade2&3) in workbook2&3 and paste to workbook1. But the data in workbook2&3 sheet(grade2&3) will automatically paste in workbook1 sheet(record grade 1 - grade 3) in column grade 2..
View 6 Replies
View Related
Jun 23, 2014
I am coping form "SAC May'14 workfile" sheets "Top 20 FM" & "FM Major Inc&Dec" to "SAC Register Analysi Template" sheet "Top 20 FM" work perfectly but if i copy from e.g "SAC Feb'14 workfile, March'14 workfile" etc..
I have attached the file for ease of reference.
View 4 Replies
View Related
Sep 25, 2009
i facing another problem at here and do not know how to write the part of coding. it is pending for 2 weeks. i do not know how to explain so i attach the excel to explain. i hope can get any reply soon.
View 2 Replies
View Related
May 30, 2014
I am trying to find text in one workbook and paste it into another. I've tried a Vlookup, and now I'm trying a Find, and neither is working.
This is what I have so far...
Sub FindAddress()
Dim GCell As Range
Dim Page$, Txt$, MyPath$, MyWB$, MySheet$
Txt = "N.A.V."
MyPath = "T:01862a7R228 Reports2039067"
[Code] ...........
View 9 Replies
View Related
Jan 5, 2009
I'm having a little bit of trouble with my code. I basically need to copy-paste special a large workbook (50 worksheets) into a new range-valued workbook. I've defined Sheet as S, but in some instances when I use the variable "S" I received a runtime error 1004.
Please see the highlighted red "S" in the code below.
Also, if one knew of an easier method for this particular operation that would be great!
Sub PasteSpecial()
Dim W As Workbook
Dim S1 As Worksheet
Dim S As Sheets
Set W = Workbooks("newfile2")
Set S1 = W.Worksheets("Sheet1")
Set S = Sheets
S(Array("Sheet1", "Sheet2", "Sheet3")).Select
S1.Activate
S(Array("Sheet1", "Sheet2", "Sheet3")).Copy
Cells.Select
Range("a1").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Paste:=XlPasteFormat
S("Sheet2").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Paste:=XlPasteFormat
S("Sheet3").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Paste:=XlPasteFormat
MsgBox "New Range-Valued Workbook has been created"
Application.CutCopyMode = False
End Sub
View 9 Replies
View Related
Aug 15, 2008
Currently I have a macro which successfully updates a value in the report page, creates a new document and then copies and pastes (as values)that sheet into the new workbook and saves it down as a unique file.
I need to have graphs on this new workbook. So gathered creating a template and getting the macro to open this template, copy the ranges and then paste into the template (which will update the charts) and then save down.
The ranges i need to paste in are: B5:D7, and B11:P37 the destination cells are exactly the same.
The current code i have is: ...
View 4 Replies
View Related
Jun 26, 2006
I have a master workbook and a template workbook. The template workbook when run generates a new workbook with the current date as the file name. Within the newly generated workbook, the template, had created 5 worksheets. On each worksheet, there is a single cell that contains the total from that particular worksheet.
What I need is a macro that will grab these totals, one from each of the 5 worksheets from the newly generated workbook done by the template, and pasted it in the master workbook under the 5 columns in a worksheet: 0-20, 21-40,41-60,61-80,81-100. However, the next time the macro is run, it will not over write the previous data but move to the next blank row and paste the totals there.
View 9 Replies
View Related
Nov 20, 2006
I am currentyly using VB to extract some data sets to another tab in the same workbook. I would like to extract the same data to a new workbook that is already created upon running a macro. How do I specify the location of the new workbook and sheets so the code will extract and input correctly?
The code I am currently using is:
Sub RunModel()
Dim Events As Range
'
'
Application. ScreenUpdating = False
Set Events = Worksheets("Inputs").Range("L41:L90")
Worksheets("Results").Range("A5:FX5004").Clear
Worksheets("Results").Range("A5009:FX10010").Clear
y = -100
For x = 1 To 50
View 3 Replies
View Related
Feb 14, 2007
By referring to the attached file, I have to copy all the datas which have a value only ( total=0 is ignored) in the Bin_Trip worksheet(highlight in image1 below), then all this data will be paste to other new workbook. All this job is done by clicking the start button and after user enter the directory(image2 below).
The last result consist of the workbook with the pasted datas from Bin_Trip worksheet.
image1
image2
View 9 Replies
View Related
Jul 28, 2007
Here is some sample code I found on the internet similar to mine:
Windows("Waterfall 1.xls").Activate
Cells. Find(What:="accounts", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
Windows("test Schedule.xls").Activate
ActiveCell.Offset(0, 0).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Range("A1:G1").Select
Selection.Copy
Windows("Waterfall 1.xls").Activate
ActiveCell.Offset(0, 2).Range("A1:G1").Select
ActiveSheet.paste
Windows("test Schedule.xls").Activate
ActiveCell.Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "4"
ActiveCell.Offset(0, -1).Range("A1").Selectp.
I now understand that there's a way to remove the activate statements, while still selecting that document to work with, and therefore greatly increasing the speed.
View 3 Replies
View Related