Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Installed_Piles()
- '
- ' Installed_Piles Macro
- '
- 'Sets some varibles
- Dim nwb As Workbook
- Dim nws As Worksheet
- Dim rng As Range
- Dim nrng As Range
- Dim i As Integer
- Dim j As Integer
- 'creates a new workbook and sets varible values
- Set nwb = Workbooks.Add
- Set nws = nwb.Sheets("Sheet1")
- Set nrng = nws.Range("a1")
- 'Clear filters from Data, set rng range for copying to new worksheet
- Fclear Data
- 'Data.Range("$A$6:$D$6").AutoFilter Field:=19, Criteria1:="<>"
- Set rng = Get_Data(Data, "A6", "S6", 19, "<>")
- i = rng.Rows.Count
- j = rng.Columns.Count
- 'Resize new worksheet to accept Data
- Set nrng = nrng.Resize(i, j)
- 'Copy values only over, removes unnecessary data, sets date format
- nrng.Value = rng.Value
- nrng.Columns("E:R").Delete
- nrng.Columns("E:E").NumberFormat = "mm/dd/yyyy"
- 'Save and exit new worksheet
- ChDir fpath & "\Global Mapper"
- Application.DisplayAlerts = False
- nwb.SaveAs Filename:= _
- fpath & "\Global Mapper\Installed Piles.csv" _
- , FileFormat:=xlCSV, CreateBackup:=False
- nwb.Close SaveChanges:=True
- Fclear Data
- End Sub
- Function Get_Data(ws As Worksheet, Fc As String, Lc As String, i As Integer, c As String) As Range
- 'this function is meant to accept a header range with filter criteria, it then takes that range and filters the data.
- 'this filtered data is then suppose to be sent out by the function which includes the header and all visible data.
- 'figured this would deal with zero visible data as well instead of having to search for the first visible cell.
- Dim rg As Range
- Set rg = ws.Range(Fc & ":" & Lc)
- With rg
- .AutoFilter field:=i, Criteria1:=c
- Get_Data = .Range.SpecialCells(xlCellTypeVisible)
- End With
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement