[FONT="Times New Roman"]I would really appreciate some help with this one. Ihave spent many hours on this with no results.[/FONT]
[FONT="Times New Roman"] [/FONT]
[FONT="Times New Roman"]I would like to be able to transfer specific data fromthe Quote Workbook to the Reports Workbook.[/FONT]
[FONT="Times New Roman"] [/FONT]
[FONT="Times New Roman"]In the Reports Workbook I have a sheet for each salesstaff member and a Master List. When transferring the data from the Quote, I wouldlike to send it to the sales staff (H9) selected in the quote sheet to theirsheet in the Reports Workbook as well as to the Master List. I hope this makes sense. [/FONT]
[FONT="Times New Roman"] [/FONT]
[FONT="Times New Roman"]The data from Quote Workbook cells H9, H8, C6, H6, andI41.[/FONT]
[FONT="Times New Roman"]Transfer to Reports Workbook starting in cells B5:F5 inthe selected sales staff’s sheet and Master List.[/FONT]
[FONT="Times New Roman"] [/FONT]
[FONT="Times New Roman"]I need it to record every time a quote gets made. [/FONT]
[FONT="Times New Roman"] [/FONT]
[FONT="Times New Roman"]I have attached a sample of each workbook.
Transfer Data from one Workbook to another Workbook
-
-
-
Re: Transfer Data from one Workbook to another Workbook
The Cells that you ask to be copied over do not match the columns B:F
H9 is Staff Name Column B is Name
H8 is Quote date column C is dateso those correct
C6 is Customer column D is Type of Quote
H6 is type of Quote column E is Quote Value
141 is Quote Total column F is Date SoldThese 3 do not match.
Either you are missing a column in you SampleReport Book, or do you not want Customer copied over from the quote?
-
Re: Transfer Data from one Workbook to another Workbook
If you do not want Customer Name ("Prepared For") transferred then use:
Code
Display MoreSub QuoteToReport() Dim x With ThisWorkbook.Sheets("Quote") x = Array(Split(.[h9])(0), .[h8], .[h6], .[i41]) End With With Workbooks("SampleReports") '// Change as required .Sheets("MasterList").Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 4) = x .Sheets(x(0)).Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 4) = x End With End Sub
If there should be a column between Date and Type for Customer then use:
Code
Display MoreSub QuoteToReport() Dim x With ThisWorkbook.Sheets("Quote") x = Array(Split(.[h9])(0), .[h8], .[c6], .[h6], .[i41]) End With With Workbooks("SampleReports") '// Change as required .Sheets("MasterList").Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 5) = x .Sheets(x(0)).Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 5) = x End With End Sub
-
Re: Transfer Data from one Workbook to another Workbook
Thank you so much. You are right about the Customer Name. I missed it in the sample reports.
When I run the code it gives me a run-time error and highlights the line "With Workbooks("SampleReports") '// Change as required". I did change the workbook name to the right name for my book. It is in the same folder the Quote one is.
-
Re: Transfer Data from one Workbook to another Workbook
Is the Report workbook open? If not you will either need to open it before running the code or add code to open it
-
-
Re: Transfer Data from one Workbook to another Workbook
I have tried it with the Report workbook open and it still comes back with run-time error. The Report workbook is password protected with VBA so I'm not sure how to run a code to open it. When the sales staff open the Report workbook I only want them to be able to see their own sheet.
-
Re: Transfer Data from one Workbook to another Workbook
This will open the Reports file, update it, then close it again saving the update.
Code
Display MoreSub QuoteToReport() Dim x, wb As Workbook With ThisWorkbook.Sheets("Quote") x = Array(Split(.[h9])(0), .[h8], .[c6], .[h6], .[i41]) End With Workbooks.Open "SampleReports.xlsx" With Workbooks("SampleReports") '// Change as required .Sheets("MasterList").Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 5) = x .Sheets(x(0)).Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 5) = x .Close True End With End Sub
-
Re: Transfer Data from one Workbook to another Workbook
So each Staff member has their own password, and when the workbook opens code runs to limit access to just that users sheet?
What is your code for unprotecting with password?
-
Re: Transfer Data from one Workbook to another Workbook
It still has an run-time error and now highlights "Workbooks.Open "SampleReports.xlsx". The Report workbook is a .xlsm, changed that and still nothing. Sorry for making this so difficult.
I used a tutorial from this site http://www.onlinepclearning.com/excel-userform-login/
The full code in the workbook is...
Code
Display MoreOption Explicit Private Trial As Long Private Sub cmdCheck_Click() 'Declare the variables Dim AddData As Range, Current As Range Dim user As Variant, Code As Variant Dim PName As Variant, AName As Variant Dim ws As Worksheet, ws2 As Worksheet, ws3 As Worksheet Dim result As Integer Dim TitleStr As String Dim msg As VbMsgBoxResult 'Variables user = Me.txtUser.Value Code = Me.txtPass.Value TitleStr = "Password check" result = 0 Set Current = Sheet2.Range("O8") 'Error handler On Error GoTo errHandler: 'Destination location for login storage Set AddData = Sheet2.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) 'Check the login and passcode for the administrator If user <> "" And Not IsNumeric(user) And Code <> "" And IsNumeric(Code) Then For Each AName In Sheet2.Range("T8:T108") 'If AName = Code Then 'Use this for passcode text If AName = CLng(Code) And AName.Offset(0, -1) = user Then ' Use this for passcode numbers only MsgBox "Welcome Back: – " & user & " " & Code 'record user login AddData.Value = user AddData.Offset(0, 1).Value = Now 'Add usernmae to the worksheet Current.Value = user 'Change variable if the condition is meet result = 1 'Unload the form Sheet2.visible = True Sheet2.Select Unload Me 'Show the navigation form 'frmNavigation.Show Exit Sub End If Next AName End If 'Check user login with loop If user <> "" And Not IsNumeric(user) And Code <> "" And IsNumeric(Code) Then For Each PName In Sheet2.Range("H8:H108") 'If PName = Code Then 'Use this for passcode text If PName = CLng(Code) And PName.Offset(0, -1) = user Then ' Use this for passcode numbers only MsgBox "Welcome Back: – " & user & " " & Code 'record user login AddData.Value = user AddData.Offset(0, 1).Value = Now 'Add usernmae to the worksheet Current.Value = user 'unhide worksheet for user If PName.Offset(0, 1) <> "" Then Set ws = Worksheets(PName.Offset(0, 1).Value) ws.visible = True End If 'unhide worksheet for user If PName.Offset(0, 2) <> "" Then Set ws2 = Worksheets(PName.Offset(0, 2).Value) ws2.visible = True End If 'unhide worksheet for user If PName.Offset(0, 3) <> "" Then Set ws3 = Worksheets(PName.Offset(0, 3).Value) ws3.visible = True End If 'show sheet tab if hidden ActiveWindow.DisplayWorkbookTabs = True 'Change variable if the condition is meet result = 1 'Unload the form Unload Me 'Show the navigation form 'frmNavigation.Show Exit Sub End If Next PName End If 'Check to see if an error occurred If result = 0 Then 'Increment error variable Trial = Trial + 1 'Less then 3 error message If Trial < 3 Then msg = MsgBox("Wrong password, please try again", vbExclamation + vbOKOnly, TitleStr) Me.txtUser.SetFocus 'Last chance and close the workbook If Trial = 3 Then msg = MsgBox("Wrong password, the form will close…", vbCritical + vbOKOnly, TitleStr) ActiveWorkbook.Close False End If End If Exit Sub 'Error block errHandler: MsgBox "An Error has Occurred " & vbCrLf & "The error number is: " _ & Err.Number & vbCrLf & Err.Description & vbCrLf & _ "Please notify the administrator" End Sub Private Sub UserForm_QueryClose _ (Cancel As Integer, CloseMode As Integer) ' Prevents use of the Close button If CloseMode = vbFormControlMenu Then MsgBox "Clicking the Close button does not work." Cancel = True End If End Sub
-
Re: Transfer Data from one Workbook to another Workbook
There is nothing in that code that unprotects the staff worksheet, it just determines which sheet is visible rather than hidden.
QuoteIt still has an run-time error and now highlights "Workbooks.Open "SampleReports.xlsx". The Report workbook is a .xlsm, changed that and still nothing
How can SampleReports.xlsx be highlighted if you have changed it?
What is the actual name of your Report workbook?
-
-
Re: Transfer Data from one Workbook to another Workbook
The actual name of the workbook is Reports. I just don't understand what I am doing wrong.
-
Re: Transfer Data from one Workbook to another Workbook
I changed the SampleReports.xlsx workbook to Reports.xlsm, hid all sheets except for Bev, then created a dummy quote for Cornie Peters, ran the code below, created another dummy quote for Cliff Sawatzly and ran the code again.
Then opened Reports.xlsm to check and each Staff sheet and the Master sheet (all of which were hidden) updated correctly. All was correct (I added extra column to each sheet for Customer)
Code
Display MoreSub QuoteToReport() Dim x, wb As Workbook With ThisWorkbook.Sheets("Quote") x = Array(Split(.[h9])(0), .[h8], .[c6], .[h6], .[i41]) End With Workbooks.Open "Reports.xlsm" With Workbooks("Reports") .Sheets("MasterList").Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 5) = x .Sheets(x(0)).Cells(Rows.Count, 2).End(xlUp).Offset(1).Resize(, 5) = x .Close True End With End Sub
This code is in the Quote template workbook.
-
Re: Transfer Data from one Workbook to another Workbook
I am at a complete lost here. I can not understand why it is not working for me. Could there be something in my original workbooks that is causing the problem?
-
Re: Transfer Data from one Workbook to another Workbook
I found out that the code KjBox gave me does not work on Windows 8. When I took the project to work and tested it one more time, it worked perfectly. I took it home to continue working on it and it did not work again. One of my coworkers also has Windows 8 and the same error keeps coming up. Everyone that does not have Windows 8 can use the reports code.
Anyone have an idea why it does not work on Windows 8?
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!