Hello everyone. Newer to VBA and have very litttle instruction so don't laugh.
I am trying to take a daily report with multiple skills and move this data into a yearly archive file for each skill. Sounded simple enough but I'm stuck. I keep getting an object error even when I simply record the macro and try to run it. Here is the code-- any idea's?
Dim rdate As String
Dim skill As String
Dim fpath As String
Dim spath As String
Dim wbname As String
Dim csname As String
Dim dbname As String
Dim csfile As String
Dim Drange As Range
Dim xdate As String
Sub DashboardUPDT()
wbname = ActiveWorkbook.Name
Sheets("DB").Activate
fpath = Cells(1, 1) 'dashboard file path defined
spath = Cells(2, 1) 'Daily report path defined
rdate = InputBox("Enter Report Date") ' reporting date in question
rdate = Format(rdate, "MM-DD-YYYY") ' reformat for use in file path
xdate = Format(rdate, "MM/DD/YYYY") ' reformat date for search in dashboard range
csname = spath & "Daily Summary - " & rdate & ".xlsx" ' define file path
Workbooks.Open (csname) ' open daily report
csfile = ActiveWorkbook.Name ' define daily workbook variable
For r = 5 To 52 ' time to loop
If Cells(r, 3) <> "" Then ' if skill isn't blank proceed
If Cells(r, 1) <> "x" Then 'x in col A indicates a total row
skillx = Cells(r, 3) ' define skill
skpath = fpath & skillx & ".xlsx" ' define dashboard path
Workbooks.Open (skpath) ' open dashboard
dbfname = ActiveWorkbook.Name ' define dashboard variable
Else
GoTo Nextrow ' if not a skill move on to next row
End If
End If
Workbooks(csfile).Activate ' activate daily summary
Range("J" & r & ":" & "V" & r).Select ' copy range of data associated with skill
Selection.Copy ' copy it
Workbooks(dbfname).Activate ' activate dashboard for skill in question
Range("c:c").Activate ' activate search range
'***************************Error is driving me nutz********************
Selection.Find(What:=xdate, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate ' ERROR ERROR code 91
On Error Resume Next
ActiveCell.Offset(0, 1).Select ' select cell ajacent to date found
Nextrow:
Next r
End Sub
I am trying to take a daily report with multiple skills and move this data into a yearly archive file for each skill. Sounded simple enough but I'm stuck. I keep getting an object error even when I simply record the macro and try to run it. Here is the code-- any idea's?
Dim rdate As String
Dim skill As String
Dim fpath As String
Dim spath As String
Dim wbname As String
Dim csname As String
Dim dbname As String
Dim csfile As String
Dim Drange As Range
Dim xdate As String
Sub DashboardUPDT()
wbname = ActiveWorkbook.Name
Sheets("DB").Activate
fpath = Cells(1, 1) 'dashboard file path defined
spath = Cells(2, 1) 'Daily report path defined
rdate = InputBox("Enter Report Date") ' reporting date in question
rdate = Format(rdate, "MM-DD-YYYY") ' reformat for use in file path
xdate = Format(rdate, "MM/DD/YYYY") ' reformat date for search in dashboard range
csname = spath & "Daily Summary - " & rdate & ".xlsx" ' define file path
Workbooks.Open (csname) ' open daily report
csfile = ActiveWorkbook.Name ' define daily workbook variable
For r = 5 To 52 ' time to loop
If Cells(r, 3) <> "" Then ' if skill isn't blank proceed
If Cells(r, 1) <> "x" Then 'x in col A indicates a total row
skillx = Cells(r, 3) ' define skill
skpath = fpath & skillx & ".xlsx" ' define dashboard path
Workbooks.Open (skpath) ' open dashboard
dbfname = ActiveWorkbook.Name ' define dashboard variable
Else
GoTo Nextrow ' if not a skill move on to next row
End If
End If
Workbooks(csfile).Activate ' activate daily summary
Range("J" & r & ":" & "V" & r).Select ' copy range of data associated with skill
Selection.Copy ' copy it
Workbooks(dbfname).Activate ' activate dashboard for skill in question
Range("c:c").Activate ' activate search range
'***************************Error is driving me nutz********************
Selection.Find(What:=xdate, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate ' ERROR ERROR code 91
On Error Resume Next
ActiveCell.Offset(0, 1).Select ' select cell ajacent to date found
Nextrow:
Next r
End Sub