HI Team,
I am getting this error when running the code for the task raw data file. Below is the error.
VBA error.PNG
Below bold line item in the code causing this error. Please help me to resolve this error.
Public Sub InitializeTaskRawData(functionalDemandbyStudyReportFileName As String)
Dim startTime As Double
startTime = Timer
Dim Wksht As Worksheet
Set Wksht = brainsWorkbook.Sheets("Task Summary")
Dim calculatedDateString As String
calculatedDateString = Left(Right(functionalDemandbyStudyReportFileName, 24), 19)
TaskrawDataExportFilename = "Functional Demand Task Raw Data-" & calculatedDateString & ".xlsx"
Dim taskrawDataWksht As Worksheet
Set taskrawDataWksht = Application.Workbooks.Add.Sheets(1)
taskrawDataWksht.Name = "Task Raw Data"
taskrawDataWksht.SaveAs mainExportFolder & TaskrawDataExportFilename
Dim inputReportWorkbook As Workbook
Set inputReportWorkbook = Application.Workbooks.Open(functionalDemandbyStudyReportFileName)
'Validate_InputFile
Dim rawDataRow As Long
rawDataRow = 2
Dim startColumn As Integer
startColumn = 0
Dim startRow As Integer
startRow = 13
Dim lastRow As Long
lastRow = Wksht.Cells.Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).row
Dim lastCol As Long
' lastCol = inputReportWorkbook.Sheets(1).Cells.Find(What:="*", _
' After:=Range("A1"), _
' LookAt:=xlPart, _
' LookIn:=xlFormulas, _
' SearchOrder:=xlByColumns, _
' SearchDirection:=xlPrevious, _
' MatchCase:=False).Column
lastCol = startColumn + numberOfMonths
taskrawDataWksht.Cells(1, startColumn + 1).Value = "Study"
taskrawDataWksht.Cells(1, startColumn + 2).Value = "Resource"
taskrawDataWksht.Cells(1, startColumn + 3).Value = "Region"
taskrawDataWksht.Cells(1, startColumn + 4).Value = "Task"
taskrawDataWksht.Cells(1, startColumn + 5).Value = "Travel"
startDate = DateValue(UserForm.TextBoxStartDate.Value)
stopDate = DateValue(UserForm.TextBoxStopDate.Value)
'numberOfMonths = 144 + 24 + 120
numberOfMonths = 1 + date_diff_to_months(startDate, stopDate)
taskrawDataWksht.Activate
Range("F1").Activate
'Populate the dates for as many months has have been selected
Dim j As Integer
For j = 0 To numberOfMonths - 2
ActiveCell.offset(0, j).Value = DateAdd("m", j, startDate)
ActiveCell.offset(0, j).NumberFormat = "m/d/yyyy"
Next j
Dim taskrawDataWorkbook As Workbook
If (IsWorkBookOpen(mainExportFolder & TaskrawDataExportFilename)) Then
Set taskrawDataWorkbook = Application.Workbooks(TaskrawDataExportFilename)
Else
Set taskrawDataWorkbook = Application.Workbooks.Open(mainExportFolder & TaskrawDataExportFilename)
End If
'taskrawDataWorkbook.Close True
End Sub
Thanks
Bookmarks