Hi folks,
im a little stuck as ever!!!
the following code:
Sub GetDiscoData()
Dim SSheet As String
SSheet = InputBox("What Would you like to call the sheet?", "Name Sheet:") 'WeekNumber and Hour Here?
Range("B5").Value = SSheet
ActiveWorkbook.Worksheets.Add
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=N:\BILLING\Business Billing\DISCO\Work\New\Discos.mdb;Mod" _
, _
"e=Read;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:E" _
, _
"ngine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLED" _
, _
"B:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale o" _
, _
"n Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False" _
), Destination:=Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array("Base")
.Name = "Discos"
.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 = "N:\BILLING\Business Billing\DISCO\Work\New\Discos.mdb"
.Refresh BackgroundQuery:=False
End With
Dim Sname As String
Dim Snew As String
Snew = Sheets("Home").Range("B5").Value
ActiveSheet.Name = Snew
End Sub
Basically it gets data from a database, sticks it in excel an renames the sheet, but i want to name the sheet as Follows:
Wk50Hr12
So basically the current Week number (50 at present) and the Current Hour (12 at the moment) but i don't know how i can achieve this.
please help folks!!!
thanks for reading
Bookmarks