hello everyone i have a lot of code recorded
and i would like some help in making the code more compact-readable if possible
2 lines in 1?
sort option?
and finally the recorded part for external data:
thanks in advance for any help
and i would like some help in making the code more compact-readable if possible
2 lines in 1?
Code:
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Data"
Sheets(Array("Sheet2", "Sheet3")).Select
ActiveWindow.SelectedSheets.Delete
ActiveWorkbook.SaveAs "C:\Data.xls"
......
Columns("G:G").Select
ActiveWindow.FreezePanes = True
Columns("K:L").Insert Shift:=xlToRight
Columns("N:N").Insert Shift:=xlToRight
Range("K1").Formula = "F1"
Range("L1").Formula = "F2"
Range("N1").Formula = "F3"
Range("K1").Select
Selection.AutoFilter
Workbooks.Open Filename:="C:\Info.xls"
Worksheets(Array("F1", "F2", "F3")).Copy Workbooks("Data.xls").Worksheets(1)
Windows("Info.xls").Activate
ActiveWindow.Close
Sheets("Data").Select
sort option?
Code:
Range("A1:W" & LR).Sort Key1:=Range("F2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
and finally the recorded part for external data:
Code:
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\AllSales.m" _
, _
"db;Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Passw" _
, _
"ord="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Trans" _
, _
"actions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:D" _
, _
"on't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array("Helen")
.Name = "db1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = _
"C:\AllSales.mdb"
.Refresh BackgroundQuery:=False
thanks in advance for any help