Hello,
I current have a macro which saves data from cells to another worksheet in the excel file called results.
Is it possible to save this data to a different workbook? Basically I want to save performance scores each month and don't want the whole company to be able to view these on the template.
Also, is it possible to build a macro that saves the file in a set format. I have a cell which has the name, month & date. Is it possible to have a macro that saves the file as namemonthdate.xls in a set folder?
The macro I have which currently exports the data to the results spreadsheet is
Sub ButtonClick()
Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range
'cells to copy from Input sheet - some contain formulas
myCopy = "X6,I6,B6,S6,N2,T2,AH10,AH14,AH18,AH22,AH28"
Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Results")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With
With inputWks
Set myRng = .Range(myCopy)
If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox "Please complete all the boxes. If not applicable, enter N/A"
Exit Sub
End If
End With
With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With
'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConstants)
.ClearContents
Application.Goto .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub
Thanks,
Gemma
I current have a macro which saves data from cells to another worksheet in the excel file called results.
Is it possible to save this data to a different workbook? Basically I want to save performance scores each month and don't want the whole company to be able to view these on the template.
Also, is it possible to build a macro that saves the file in a set format. I have a cell which has the name, month & date. Is it possible to have a macro that saves the file as namemonthdate.xls in a set folder?
The macro I have which currently exports the data to the results spreadsheet is
Sub ButtonClick()
Dim historyWks As Worksheet
Dim inputWks As Worksheet
Dim nextRow As Long
Dim oCol As Long
Dim myRng As Range
Dim myCopy As String
Dim myCell As Range
'cells to copy from Input sheet - some contain formulas
myCopy = "X6,I6,B6,S6,N2,T2,AH10,AH14,AH18,AH22,AH28"
Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Results")
With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With
With inputWks
Set myRng = .Range(myCopy)
If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox "Please complete all the boxes. If not applicable, enter N/A"
Exit Sub
End If
End With
With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With
'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConstants)
.ClearContents
Application.Goto .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
End Sub
Thanks,
Gemma