Below is the code I've put together. I seem to be getting hung up on the Sendkeys portion. What I'm trying to accomplish is...
I have one excel sheet that generates my report: "Test Invoice Report". Using the data generated from the report I would like my macro to allow the user to enter a Billing Date which would become part of the filename for the newly created sheet. The file name would then become "Test Billing Report 07 01 09". I would like to switch back to the report and copy rows 10 and down which contain data and paste them in to this newly created sheet. The sheet's name will always be different and there for I was trying to use the ALT-Tab method to get around that. Please let me know if I need to clarify anyting.
If anyone has a suggestion or better way to accomplish this it would be greatly appreciated.
Thanks in advance for the help!
Sub Save()
'
'
Dim Filename As String
Workbooks.Add
ChDir "S:\Test"
Filename = InputBox("Please input billing date:", "Filename")
ActiveWorkbook.SaveAs Filename:="S:\Test\Test Billing Report " & Filename, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
'
'
Windows("Test Invoice Report.xls").Activate
Rows("10:10").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Application.SendKeys "%{TAB}"
Range("A1").Select
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
'
'
End Sub
Will Lewis
I have one excel sheet that generates my report: "Test Invoice Report". Using the data generated from the report I would like my macro to allow the user to enter a Billing Date which would become part of the filename for the newly created sheet. The file name would then become "Test Billing Report 07 01 09". I would like to switch back to the report and copy rows 10 and down which contain data and paste them in to this newly created sheet. The sheet's name will always be different and there for I was trying to use the ALT-Tab method to get around that. Please let me know if I need to clarify anyting.
If anyone has a suggestion or better way to accomplish this it would be greatly appreciated.
Thanks in advance for the help!
Sub Save()
'
'
Dim Filename As String
Workbooks.Add
ChDir "S:\Test"
Filename = InputBox("Please input billing date:", "Filename")
ActiveWorkbook.SaveAs Filename:="S:\Test\Test Billing Report " & Filename, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
'
'
Windows("Test Invoice Report.xls").Activate
Rows("10:10").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Application.SendKeys "%{TAB}"
Range("A1").Select
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
'
'
End Sub
Will Lewis