AndyFarrell79
New Member
- Joined
- Mar 17, 2014
- Messages
- 7
Hi All,
I've not had much experience with VBA code, other than recording macros and editing them a little. What i would like to do is code a macro to copy the data (text only) of a whole worksheet into a blank worksheet in a different workbook, effectively allowing the user to "upload" the data to a master workbook.
The user will complete data entry into a daily template worksheet containing all formulae to obtain necessary daily data. I would like them to then be able to click a button that runs a macro copying the text data from the daily template to a monthly workbook. I have no problem recording this in a macro and the code for that (no doubt there is a more efficient way) is:
Sub Load_Report()
'
' Load_Report Macro
'
'
Workbooks.Open Filename:= _
"C:\Users\afarrell\Desktop\New-PSR Re-Structure\Jan.xlsx"
Windows("Production Supervisors Report.xlsm").Activate
Cells.Select
ActiveSheet.Shapes.Range(Array("Group 37")).Select
Cells.Select
Selection.Copy
Windows("Jan.xlsx").Activate
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
Range("B8:V8").Select
End Sub
The monthly workbook will contain 31 sheets (named 1,2,3...31) for the days, and each month will have it's own workbook (named Jan, Feb, Mar...Dec).
The key thing I need help with is using cells within the daily workbook to determine the month and day used by VBA for the filename and worksheet respectively.
Cell B5 contains the day (eg. 1) and C5 the month (eg. Jan)
Any help on this would be immensely appreciated!
Regards,
Andy
I've not had much experience with VBA code, other than recording macros and editing them a little. What i would like to do is code a macro to copy the data (text only) of a whole worksheet into a blank worksheet in a different workbook, effectively allowing the user to "upload" the data to a master workbook.
The user will complete data entry into a daily template worksheet containing all formulae to obtain necessary daily data. I would like them to then be able to click a button that runs a macro copying the text data from the daily template to a monthly workbook. I have no problem recording this in a macro and the code for that (no doubt there is a more efficient way) is:
Sub Load_Report()
'
' Load_Report Macro
'
'
Workbooks.Open Filename:= _
"C:\Users\afarrell\Desktop\New-PSR Re-Structure\Jan.xlsx"
Windows("Production Supervisors Report.xlsm").Activate
Cells.Select
ActiveSheet.Shapes.Range(Array("Group 37")).Select
Cells.Select
Selection.Copy
Windows("Jan.xlsx").Activate
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWindow.Close
Range("B8:V8").Select
End Sub
The monthly workbook will contain 31 sheets (named 1,2,3...31) for the days, and each month will have it's own workbook (named Jan, Feb, Mar...Dec).
The key thing I need help with is using cells within the daily workbook to determine the month and day used by VBA for the filename and worksheet respectively.
Cell B5 contains the day (eg. 1) and C5 the month (eg. Jan)
Any help on this would be immensely appreciated!
Regards,
Andy