HEALTHSTAFF
New Member
- Joined
- Oct 5, 2017
- Messages
- 12
Hello,
I have two workbooks one is for making bookings and a second that has a list of numbers allocated to vouchers.
Workbook one has data like surname, date of appointment & staff initials. I want this data transferred to workbook 2 which is where we allocate voucher numbers to clients. The second workbook(which would be closed) has 4 columns Voucher number, surname, appointment date and staff initials. Voucher numbers are already listed in the worksheet. I have two lots of code I have cobbled together (sort of a noob). I would like the data added to workbook 2 based on a cell value in workbook 1. eg if the client needed 2 vouchers the name & details would be added to workbook 2 twice one line under the other in column "B" It has some errors which i thought a guru may be able to look at for me. I know some of the code is lengthy and could be done faster. Its getting stuck at the paste data stage.
Many Thanks
Workbook 1 Part 1
Second Part Workbook 1
I have two workbooks one is for making bookings and a second that has a list of numbers allocated to vouchers.
Workbook one has data like surname, date of appointment & staff initials. I want this data transferred to workbook 2 which is where we allocate voucher numbers to clients. The second workbook(which would be closed) has 4 columns Voucher number, surname, appointment date and staff initials. Voucher numbers are already listed in the worksheet. I have two lots of code I have cobbled together (sort of a noob). I would like the data added to workbook 2 based on a cell value in workbook 1. eg if the client needed 2 vouchers the name & details would be added to workbook 2 twice one line under the other in column "B" It has some errors which i thought a guru may be able to look at for me. I know some of the code is lengthy and could be done faster. Its getting stuck at the paste data stage.
Many Thanks
Workbook 1 Part 1
Code:
Sub Bluebuttonpress()
printbluecabsign
Dim y As Workbook
Dim i As Long
For i = 1 To ThisWorkbook.Worksheets("FRONT SHEET").Range("C17").Value
Call datacabcharge
Next
End Sub
Second Part Workbook 1
Code:
Sub datacabcharge()
Dim y As Workbook
Dim NextRow As Range
'## Open both workbooks first:
Set x = ThisWorkbook
Set y = Workbooks.Open("W:\WACHS-GS\Blah\departments\Medical Records Department\MR New\MR STAFF\Craig\Craig PATS\Cabcharge registerXXXX.xlsm")
'Now, copy what you want from x:
Workbooks("AAA PATIENT BOOKING TEMPLATE XXXX - Rex Flights.xlsm").Activate
Worksheets("FRONT SHEET").Range("E37:G37").Copy
Workbooks("Cabcharge registerXXXX.xlsm").Activate
Dim lastrow As Long
lastrow = Range("B" & Cells.Rows.Count).End(xlUp).Offset(1, 0).Select
Selection.Cells(lastrow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
y.Save
y.Close
End Sub
Last edited: