I am trying to create the code for XML import and then copy the content to new sheet.
- Apply filter for values other then Zero
- Copy the values to new sheet and remove Duplicates from Colomn 4.
- Save the new Sheet in Location
Code:
Sub NEISO()
'
' Macro1 Macro
'
'
Workbooks.Open "\\wltsan03\common\energy_vol\users\JOHALN\Desktop\practice\RAW FILES\NEISO.xml", ReadOnly:=True
If Range("A2") = Empty Then
MsgBox _
prompt:="Count of MW ZERO", _
Buttons:=vbOKOnly, _
Title:=" NEISO "
Sheets("Sheet1").Select
Sheets("Sheet1").Copy
ActiveWorkbook.SaveAs Filename:="\\wltsan03\common\energy_vol\users\JOHALN\Desktop\practice\Copy of NEISO.xlsx", FileFormat _
:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
Else
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
ActiveSheet.Range("$A$1:$G$289").AutoFilter Field:=4, Criteria1:="<>0", _
Operator:=xlAnd
Cells.Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$G$1048476").RemoveDuplicates Columns:=3, Header:= _
xlYes
Range("M6").Select
ActiveCell.FormulaR1C1 = "=COUNTA(C[-12])-1"
Range("M6").Select
Selection.Font.Bold = True
MsgBox _
prompt:="Sum Of MW is " & Range("M6").Value, _
Buttons:=vbOKOnly, _
Title:=" NEISO "
Sheets("Sheet2").Select
Sheets("Sheet2").Copy
ActiveWorkbook.SaveAs Filename:="\\wltsan03\common\energy_vol\users\JOHALN\Desktop\practice\Copy of NEISO.xlsx", FileFormat _
:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
End If
End Sub
No comments:
Post a Comment