Copy Range Of Cell From One Workbook To Another And Email
Nov 3, 2013I need to copy a range of cells from one workbook paste into another and email that new work book.
View 3 RepliesI need to copy a range of cells from one workbook paste into another and email that new work book.
View 3 RepliesI have 2 workbooks. 1 is where data is entered called wksPB, the other is like a database workbook. The wksPB has data to be feed from column B to F and there is a dropdown.
what im looking to do is, if the combobox value is selected as Decline then it should display a messagebox that reference value in cell B is denied. if combobox value is Agreed then the macro should search the database workbook for the text entered in column b of wksPB and then copy data of C:E of wksPB to H:J of database sheet where that text is found and also the approver name in wksPB C24 to the approver cell of where that text was found. I've reached till finding the text but what I get my head twiting on is how to copy the text from wksPB column B:F to database sheet column H:K. Im attaching the sample workbooks and the code where ive reached till.
[Code] .....
Attached Files
Replacement Records - 2014.xlsx
forum file.xlsm
Trying to copy a range from Sender.xls (sheet) Lists backstage
onto Userform.xls (sheet) Behind the Scenes
When trying to copy the values within a multicell range, the destination cell range (same size) becomes blank.
I want my macro to be able to mail the active workbok through outlook using the email addressses in Cell R1 and having the body of the email have the text in cell R2:R8?
Dim OutApp As Object
Dim OutMail As Object
Dim ws As Worksheet
Dim range as range
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = ws.Range("R1:R8").Value
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = ws.Range("R2:R8").Value
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
I have 400 source files containing (among others) 8 sheets with daily results: "Fri 23", "Mon 26", "Tue 27", "Wed 28", "Thu 29", "Fri 30", "Sat 31 (if applicable)", "Mon 2".
Each sheet contains also:
State - D1
Role - D2
Staff ID - D3
Date - D4
Activity group name in column A (starting from row 8)
Activity type in column B (merged with C and D) (starting from row 8)
Activity time in columns E:GV (starting from row 8). Usually, there is none or only one value in whole range (e.g. E8:GV8). But sometimes there are two values.
Customer ID in row 6 (value appears only if time was reported in E:GV range)
CC Number in row 7 (value appears only if time was reported in E:GV range)
It's all about transferring values from all daily sheets in all files (.xls) sitting in folder C:WADFinal to one simple table (WAD_Consolidation_file.xls, sheet "Consolidated") consisted of 9 columns: Staff ID, Role, State, Date, Activity Group, Activity Type, Minutes, Customer ID, CC Number.
to add additional questions to this link it says that the thread is expired so here i have posted a new thread.
Copy Cells To New Workbook If Match Criteria what i need is to copy the cells in new workbook "as is" i mean copy only the values and not the formula.
I've wrote a function that allows me to insert a certain range to the body of an email. This email is composed in the code, too.So far I am able to build the emails body as plain text. how to retain the cell format also (colors, font size, border styles, ...)
View 14 Replies View RelatedI have a table in excel that I would like to copy into an email and send to my co-workers on a regular basis. Somewhere on the net I have find a piece of code (I've omitted a bunch of stuff here):
View 2 Replies View RelatedI am successfully opening a .csv file using a variable value stored in a named range in my Main file (the variable includes the directory and path).
I copy data from the .csv file to the Main file then I need to close the .csv file without saving but I want to do that by using the
Windows("xxxx").Activate
command where "xxxx" is the namedrange in my Main file which stores the .csv filename (without the directory and path prefix).
I can use the
ActiveWindow.ActivatePrevious
command but if I have another workbook open, this one closes instead of the .csv file I opened from the macro.
I realise this is probably very basic and I've searched the forums but can't find any identical postings.
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.
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?
I m not able to use the standard Excel Paste Special function when I copied a range of cells in another Excel workbook opened in a separate instance of Excel. Instead, Paste Special thinks that I have copied some non-Excel objects and gave me the Paste As options. This is not the case if I open both workbook within the same instance of Excel. Could you share with us if there is a trick to trigger the normal Paste Special options in such situations (without having to invoke Macro procedures)?
View 2 Replies View RelatedI am using Excel 2010. I have been given a task at work that can save my team a lot of time if I can solve the problem. Every month, we have a spreadsheet with about 5000 rows that we have to email. In each row, there is a range that we have to email to a specific email. For example, I would have to copy and paste Range A2-R2 in the body of the email, and then email it to whatever email is in cell S2. I would then continue this for the next 5000 lines, making it a possibility that i will be sending 5000 emails manually.
I have been trying to come up with a solution through VBA that would automatically send these emails. My goal is to automatically send the Range A2-R2 to outlook email, then cell S2 into the "To" email address box, and then automatically send it. So far, i have successfully been able to send one row, but cannot figure out how to loop it for the remainder of the rows.
A couple other key points are that I have column headings as well (Range A1-R1). If possible, I want to be able to include the column headings in the email body as well. Example - first email would be range A1-R2. second email would be range A1-R1 and A3-R3, and so forth. The body of the email would also contain a standard script, such as "Please review the information below."
The goal here is to save everyone from having to send 5000+ manual emails. This would be a big boost for my team.
Code:
Sub Email()
Dim rng As Range
Dim OutApp As Object
[Code].....
I'll soon have an ETL process that will load about 150K rows into an Excel workbook. On of the columns will be the end user's userid.
I need to autofilter that external workbook based on the end user's userid, copy that range, clear a worksheet on the current workbook, and copy that range to the current worksheet.
For example, see the attached workbooks. I need to replace the data in Source.xlsb!Cases with the data in Output.xlsb!Case_List, filtered on my userid, which we'll call foo.
I have a very brief question
dlgAnswer = Application.Dialogs(xlDialogOpen).Show
Selection.Copy
Windows("Derivative YK pricing Mod G.xls").Activate
Columns("B:B").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("C5").Select
Application.CutCopyMode = False
Windows("EXPORT1.xls").Activate
ActiveWindow.Close
As you can see, I open a workbook with the dlgAnswer, I was wondering how I could close that opened workbook
Currently I have
Windows("EXPORT1.xls").Activate
ActiveWindow.Close
however the workbook will not always be called export1.xls, I want it to close whichever one I opened earlier.
I am looking to set up a vba code for sending an email to a recipient based on whether the row AI19:AI30 shows the value 3,6,9 and i want it to send an email showing all of the 3 data all of the 6 data and all of the 9 data.
I have attached my code so far.
VB:
Private Sub Workbook_Open()
Dim w As Worksheet, c As Comment
For Each w In ThisWorkbook.Worksheets
If UCase(w.Name) <> "All Trades" Then
Select Case w.Range("AI19:AI30").Value
Case Is = 3, 6, 9
[Code]....
Is it possible for a Macro to read a cell say D:11 and copy that email address and send the active sheet to that email?
View 9 Replies View RelatedBackground
Excel 2000. I would like to be able to copy a range on worksheet 1 in workbook 1 to a range in worksheet 2 in workbook 2.
Walk - Task described above with all fixed identities.
Double- Can the task be performed using variables (sheets(variablee)) for the worksheets and ranges?
Home Run - Can task be done with variables in workbook, worksheet, and range? Or just recommend a book or link that can get me there.
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
On one workbook I have "column A" that lists serial #'s, one serial number per cell. What I need is to be able to take all the non blank data from that column and copy it to another workbook with all those serial #'s in 1 cell numerically sorted and separated by commas.
View 1 Replies View RelatedI am trying to copy a small range from one sheet in a workbook to another sheet in a different workbook. My ranges are spelled out in the SrcBook and the DestBook in the code below:
Sub CopyData()
Dim SrcBook As Workbook
Dim DestBook As Workbook*
****Application.ScreenUpdating = False
****Set SrcBook = ThisWorkbook
***
*** '*On Error Resume Next
****Set DestBook = Workbooks.Open("E:WIPIWS WIP.xls")
*** '*If Err.Number = 1004 Then
********Set DestBook = Workbooks.Add
********SrcBook.Worksheets(1).Range("D4:D6").Copy
********DestBook.Worksheets(1).Range("C10").PasteSpecial.Values
********Application.CutCopyMode = False
********DestBook.SaveAs ("E:WIPIWS WIP.xls")...........................
I want to copy a range (Columne J: first row to rows.count) from one workbook to another workbook which already exists. The target range is always different. The code I have is:
So far it only copies ONE cell, but even that doesn't work. I would need the whole range to be copied!
Sub FinalImport()
Call WhatRows 'to get the intZeile variable (number) via a inputbox
Workbooks("import.txt").Sheets("Sheet1").Range("J" & Rows.count).Copy _
Workbooks("Air Distance Table.xls").Sheets("Sheet1").Range("D" & intZeile)
End Sub
This happened because I mentioned worksheet instead of workbook. The purpose of my code is as below:
1. Add new workbook (say wb2)
2. Activate the workbook wb2
3. Copy a predefined range from already open workbook (say wb1)
4. Select the target cell in wb2 through user prompt by using mouse or keyboard
5. Paste the copied range from wb1 at the selected location of wb2
I am facing problem in selecting the cell in wb2 as wb1 always remain in foreground and new workbook does not come to foreground even I click on that.
What I wanted to mean by user form is that before the above code runs, another code runs that brings up one user form. In that user form user can select if he/she wants to copy the selected range to a new workbook or an existing workbook. Suppose user selects new workbook. This time the inputbox comes and asks user to select the target cell of the new workbook. The input box pops up but I can not select the cell in new workbook as the user form always stay there and does not allow the second work book to come in front.
I ran the above code seperately without running the user form code and it worked perfectly. Hence I would like to know how to deactivate the user form
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 RelatedI have a currently working macro to copy the current sheet as values and create a new workbook in the same folder destination. That code is as follows:
View 10 Replies View RelatedI have a code that will allow me to copy three worksheets from an open workbook to a new workbook. That works great, but I only need only a selected range from each of these worksheets to be copied (Range A1:AV60). Here is the code I use to select and copy the worksheets, how do I add a range within this code for each worksheet.
Sheets(Array("Req Page 1", "Req Ext 1", "Req Ext 2")).Copy
I am using command buttons to perform various macros.
I have worksheetA with a defined range of cells of information that i sometimes want to copy to the index file. I click the command button to run the macro that copies the range to the next available row in #Index.xls
How can i change the following macro to only copy the values, and NOT the formatting?
Also, why does this particular macro cause the Command Button to remain stuck in the pressed position? It is the only command button triggering a macro that actually stays pressed, requiring my to click it again to depress it.
here is the macro i have so far:
-----------------------------------
Sub copy_to_index()
Dim bk As Workbook
Dim bSave As Boolean
Dim lRow As Long
' test to see if #Index.xls is already open
On Error Resume Next
Set bk = Workbooks("#index.xls")
On Error GoTo 0
If bk Is Nothing Then...........
In my project I have two workbooks. I am working on getting one to pull data from another depending on which employee is selected from a drop down list.
TestLOG.xls contains a worksheet for each employee, with named sections within for various training the employee has, and down each row has information on the date this was received, initial, recurrent, etc. It is only this single worksheet for each employee that any data entry occurs, which makes things a lot more organized and efficient.
TestFORMS.xls is the workbook accessed by the records department which has different worksheets depending on what data is to be presented. When an employees name is selected, I need the form to pull the specific data from another workbook, and post it on the current worksheet. This get repeated a couple times to fill the adjacent columns of data. I can't just select the whole table from the other workbook because in this current worksheet for example, only specific columns are pulled from the other workbook.
To better explain the flow...
Current workbook is TestFORMS.xls
Current sheet is Test
Closed workbook is TestLOG.xls
In TestFORMS, sheet Test, when named cell Employee is selected with a value...
Then open TestLOG in the background and open sheet of same name as Employee, and cope range ACtype.
Back in TestFORMS, sheet Test, paste the ACtype data in the range named Type.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Ename As String
Ename = Range("Employee").Value
If IsEmpty(Ename) Then Exit Sub
Workbooks("TestLOG.xls").Sheets(Ename).Range("ACtype").Select
Selection.Copy
Workbooks("TestFORMS.xls").Sheets("Test").Activate
Range("Type").PasteSpecial Paste:=xlPasteValues
End Sub
Within the same sub, I would add additional lines of code to copy and paste the other ranges needed on the current worksheet.
My current hangup is that I get an error at Range("ACtype") as that is not the proper way to call the range.
There's more work to be done with the macro yet, like having it pull the data with TestLOG closed, which I believe is done by listing the path to filename.
Then I need to maintain cell formatting on the new table when the data is posted to it.
Hopefully the final task is to get this working so that when a new employee is selected in TestFORMS, the previous employees data is cut and the new posted, as the worksheet is just printed out for each employee and put on hardfile.
i have 2 workbooks attached, in the "work order masterlist 2006.xls" workbook, i'm trying to compare column F which is the R date to see if it matches the dates in the "2006 Calendar.xls". if it's the same date, i would like to copy from "work order masterlist 2006.xls", column C, which is the Client's name to "2006 Calendar.xls" under its appropriate date, assuming that:Dates of the months will not change column/row in the "2006 Calendar.xls"it will be an added bonus if i can copy and paste the description as a comment...
View 3 Replies View RelatedI need to copy the same data range from Sheet 1 of different workbooks in the same subdir to output.xls (also in the same subdir).
In workbook output.xls, I've defined the range of workbooks (source files) as name filenames. I need to copy the same data range (say B8:R8) from each source file to the cells adjacent to the filenames in output.xls.
Eg. I have defined the range of files to copy data from as filenames in Col A of Sheet 1 in output.xls.
Col A
sales_10-09-06
sales_10-10-06
sales_10-11-06
Workbook sales_10-09-06 contain sales data of various product to different firms as below:
Col A Col B Col C .................................. Col R
prod A prod B prod q
Firm 1 50 20 100
Firm 2 20 25 80
Firm 3 30 50 20
How do I copy B8:R8 of sales recorded for each day in sales_date.xls to Col B of Sheet 1 in output.xls? There are 200 files (specified by the name filenames in output.xls) that I need to copy B8:R8 from.