I have two excel sheets. 06-03-11 tmp.csv and call log master.xlsx. I have opened call log master.xlsx - so it is my active workbook.
I have the following code starting my macro. Will call it "startercode" for reference in this posting
startercode:
if rpttype is "" (blank), I want to perform the following code (will call it "copycode" for refernce in this posting
copycode:
Column E contains values of career services, admissions, and blank cells. if rpttype = "career services",
I want to do
startercode
careercode (listed below)
copycode
careercode:
the real world reason for the coding difference is that if it is a career services report it only shows the names that have career services in column e. other than that it shows all the names.
Also the date on the tmp.csv file can change so that is why I am using the inputbox for that part.
I am not sure of the best way to do this. I understand that if-then statements work but I was not sure how they worke with multiple commands within the actions portions.
I have the following code starting my macro. Will call it "startercode" for reference in this posting
startercode:
HTML:
'***Set variables/Input boxes***
Dim tmpdate As String
Dim rpttype As String
tmpdate = InputBox("What is the TMP Date?")
rpttype = InputBox("What is the Report Type")
tmpfilename = tmpdate & " tmp.csv"
filename = rpttype & "call log master.xlsx"
'***clear current numbers*********
Range("V1:Y1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
'***open csv file*********
ChDir _
"C:\Users\smakatura\Documents\call report\"
Workbooks.Open filename:= _
"C:\Users\smakatura\Documents\call report\prep documents\" &
tmpfilename
if rpttype is "" (blank), I want to perform the following code (will call it "copycode" for refernce in this posting
copycode:
HTML:
'***copy and paste from tmp.csv to call log master.xlsx*********
Range("A2:D2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows(filename).Activate
Range(v1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
Column E contains values of career services, admissions, and blank cells. if rpttype = "career services",
I want to do
startercode
careercode (listed below)
copycode
careercode:
HTML:
'***select only Career Service entries*********
Range("F1").Select
ActiveCell.FormulaR1C1 = "CS?"
Selection.AutoFilter
Range("F2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=""career services"",""x"","""")"
Range("F2").Select
Selection.AutoFill Destination:=Range("F2:F1499")
Range("F2:F1499").Select
Range("A1").Select
ActiveWorkbook.Worksheets("06-03-11 tmp").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("06-03-11 tmp").AutoFilter.Sort.SortFields.Add Key _
:=Range("F2"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("06-03-11 tmp").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Range("$A$1:$F$1499").AutoFilter Field:=6, Criteria1:="<>"
the real world reason for the coding difference is that if it is a career services report it only shows the names that have career services in column e. other than that it shows all the names.
Also the date on the tmp.csv file can change so that is why I am using the inputbox for that part.
I am not sure of the best way to do this. I understand that if-then statements work but I was not sure how they worke with multiple commands within the actions portions.
Last edited: