Hi Guys, I am trying to do the following:
1. I have a Master sheet, in this sheet I need to enter some details regarding patients, once I click Save entry, I want three things to happen.
a) Generate a new sheet called as the patient name and I want to see all the patient information
b) Populate another sheet called (Database) with all the entries that I add
c) Once I click Save entry and point a and b happened I want to clear the row 3 in Master (to be able to enter another patient)
I was using this code and was genereting the sheets witht the name and the patient information, and was populating the database sheet too, however, in the database sheet did not go to the next row, just overwrite the first row, but for some reason stoped working.
Sub createPatientSheet()
Dim lastRow As Long
Dim cont As Long
Dim patientName As String
Dim exist As Boolean
On Error Resume Next
lastRow = sheetMaster.Range("A" & Rows.Count).End(xlUp).Row
For cont = 3 To lastRow
exist = False
patientName = sheetMaster.Cells(cont, 1)
exist = Not Worksheets(Master) Is Nothing
If exist = False Then
sheetTemplate.copy after:=Worksheets(Sheets.Count)
activeSheet.Name = patientName
End If
Sheets("Master").Range("A3:AS3").copy
Sheets("Active.sheet").Activate
Range("A2").Select
activeSheet.Paste
Application.CutCopyMode = False
Sheets("Master").Range("A3:AS3").copy
Sheets("Active.sheet").Activate
Range("A2").Select
Sheets("DataBAse").Paste
Application.CutCopyMode = False
Next cont
Worksheets("Master").Range("a3:as3").ClearContents
End Sub
a)
b)
1. I have a Master sheet, in this sheet I need to enter some details regarding patients, once I click Save entry, I want three things to happen.
a) Generate a new sheet called as the patient name and I want to see all the patient information
b) Populate another sheet called (Database) with all the entries that I add
c) Once I click Save entry and point a and b happened I want to clear the row 3 in Master (to be able to enter another patient)
I was using this code and was genereting the sheets witht the name and the patient information, and was populating the database sheet too, however, in the database sheet did not go to the next row, just overwrite the first row, but for some reason stoped working.
Sub createPatientSheet()
Dim lastRow As Long
Dim cont As Long
Dim patientName As String
Dim exist As Boolean
On Error Resume Next
lastRow = sheetMaster.Range("A" & Rows.Count).End(xlUp).Row
For cont = 3 To lastRow
exist = False
patientName = sheetMaster.Cells(cont, 1)
exist = Not Worksheets(Master) Is Nothing
If exist = False Then
sheetTemplate.copy after:=Worksheets(Sheets.Count)
activeSheet.Name = patientName
End If
Sheets("Master").Range("A3:AS3").copy
Sheets("Active.sheet").Activate
Range("A2").Select
activeSheet.Paste
Application.CutCopyMode = False
Sheets("Master").Range("A3:AS3").copy
Sheets("Active.sheet").Activate
Range("A2").Select
Sheets("DataBAse").Paste
Application.CutCopyMode = False
Next cont
Worksheets("Master").Range("a3:as3").ClearContents
End Sub
a)
b)