How would I make this program work? VBA
I am making a timesheet program and I want to convert a week on a monthly chart to a weekly chart. To do this I have coded in a module something similar to this:
Sub Open_Excel_Wb()
Workbooks.Open Filename:= _
"C:Documents and SettingsGarboMy DocumentsBook1.xls"
Sheets("Sheet2").Select
Range("A1").Select
Range("A1").Value = DateValue(Now())
End Sub
How would I then make Range("A1").Value = a value on a worksheet in an entirely different .xls file
Worksheets("CSTreport").range("N" & i).Value I have been using something similar to this within a workbook but I do not know what to add to specify it’s pathway on the computer. (i.e. C:… whatever)
P.S. Not only am I new to programming but I’m relatively new to forums. (at least posting) So try not to flame me to much
Try [WorkbookPathFilename.xls]Sheet2
ex
Worksheets("[WorkbookPathFilename.xls]Sheet2").blah blah
I didn’t actually try this out, but thats the convention with pan-workbook cells
|
Try [WorkbookPathFilename.xls]Sheet2
ex Worksheets("[WorkbookPathFilename.xls]Sheet2").blah blah I didn’t actually try this out, but thats the convention with pan-workbook cells |
Sub wbopen()
Dim ws As String
Dim wsrich As String
Dim pnumber As String
Dim familyname As String
Dim firstname As String
Dim csnumber As String
Dim calendarweek As Integer
Dim year As Integer
Dim i As Integer
i = 12
wsrich = Workbooks("C:Documents and SettingslongestDesktop Project FolderWeekly Report modelsMost recent modelnewapproach2replaced8updatesaveex.xls").Shee ts("TimesheetR")
ws = Workbooks("C:TOOLAccountWeeklyReport.xls").Shee ts("Timesheet")
pnumber = wsrich.range("c9")
familyname = wsrich.range("J9")
firstname = wsrich.range("S9")
year = wsrich.range("BA9")
calendarweek = 0
Workbooks.Open Filename:="C:TOOLAccountWeeklyReport.xls"
Sheets("Timesheet").Select
range("A1").Select
range("A1").Value = pnumber
End Sub
This is what it’s become since yesterday. I’m getting subscript 9 errors for the ws and wsrich definitions and invalid compile errors for the use of wsrich in the other variables definitions. Maybe that gives you more info?
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.