Project 2 - Create a report using PowerQuery, Macro VBA, List Functions and Data Validation functions for Data Reporting of Supply Chain Management companies
1)
Public Sub dataformating()
Dim myrange As Range
Set myrange = Range("a1:dr307512")
myrange.FormatConditions.Add Type:=x1cellvalue, opertaor:=x1between, _
Formula1:="100", Formula2:="150"
myrange.FormatConditions(1).Interior.Color = RGB(156, 0, 0)
myrange.FormatConditions.Add Type:=x1cellvalue, opertaor:=x1less, _
Formula1:="100"
myrange.FormatConditions(2).Interior.Color = vbGreen
myrange.FormatConditions.Add Type:=x1cellvalue, opertaor:=x1greater, _
Formula2:="150"
myrange.FormatConditions(3).Interior.Color = vbviolet
myrange.FormatConditions.Add Type:=x1cellvalue, opertaor:=x1less, _
Formula1:="100"
myrange.FormatConditions(2).Interior.Color = vborange
End Sub
2)
Public Sub savetopdf()
Dim thisrng As Range
Dim strfile As String
Dim myfile As Variant
If Selection.Count = 1 Then
Set thisrng = Application.InputBox("Select a range", "get range", Type:=8)
Else
Set thisrng = Selection
End If
strfile = "selection" & "_" _
& Format(Now(), "yyyymmdd_hhmmss") _
& ".pdf"
strfile = ThisWorkbook.Path & "\" & strfile
myfile = Application.GetSaveAsFilename _
(InitialFileName = strfile, _
filefilter:="pdf files(*.pdf), *.pdf", _
Title:="select folder and file name to save as pdf")
If myfile <> "False" Then
thisrng.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
myfile, quality:=x1qualitystandard, includedocproperties:=True, _
ignoreprintareas:=False, openafterpublish:=True
Else
MsgBox "no file selected. pdf will not be saved", vbOKOnly, "no file selected"
End If
End Sub
3)
Sub HighlightMisspellings()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
'Check the spelling and if it's wrong, then change the style to be Accent2
If Not Application.CheckSpelling(word:=cell.Text) Then
cell.Style = "Accent2"
End If
Next cell
End Sub