Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
changing a section of text
I have a macro that runs two queries and returns the data to a repot. I
need to be able to edit two dates in two different locations each time the macro runs. Is there a simple way of doing this by entering the values on the spreadsheet? The dates 30-aug-2005 and 31-aug-2005 are what I need to change. Thanks in advance for any help you can give. Private Sub CommandButton1_Click() Sheets("Sheet1").Select ActiveSheet.PivotTableWizard SourceType:=xlExternal, SourceData:=Array( _ "SELECT ss_hist_base.mach_name, ss_hist_base.shift_id, Sum(ss_hist_base.total_down_time)" & Chr(13) & "" & Chr(10) & "FROM plantstar.ss_hist_base ss_hist_base" & Chr(13) & "" & Chr(10) & "WHERE (ss_hist_base.start_time='30-aug-2005 07:00:00' And ss_hist_ba" _ , _ "se.start_time<'31-aug-2005 07:00:00')" & Chr(13) & "" & Chr(10) & "GROUP BY ss_hist_base.mach_name, ss_hist_base.shift_id" _ ), Connection:= _ "ODBC;DSN=OPENINGRES;SERVER=PLANTSTAR;DATABASE=foc us2000;SERVERTYPE=INGRES" ActiveSheet.PivotTables("PivotTable2").SmallGrid = False ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:=Array("mach_name" _ , "shift_id", "col3") Sheets("report").Select Sheets("sheet3").Select ActiveSheet.PivotTableWizard SourceType:=xlExternal, SourceData:=Array( _ "SELECT ss_hist_base.mach_name, ss_hist_base.tool, ss_hist_base.shift_id, Sum(ss_hist_base.total_down_time)" & Chr(13) & "" & Chr(10) & "FROM plantstar.ss_hist_base ss_hist_base" & Chr(13) & "" & Chr(10) & "WHERE (ss_hist_base.start_time='30-aug-2005 07:00" _ , _ ":00' And ss_hist_base.start_time<'31-aug-2005 07:00:00')" & Chr(13) & "" & Chr(10) & "GROUP BY ss_hist_base.mach_name, ss_hist_base.tool, ss_hist_base.shift_id" _ ), Connection:= _ "ODBC;DSN=OPENINGRES;SERVER=PLANTSTAR;DATABASE=foc us2000;SERVERTYPE=INGRES" ActiveSheet.PivotTables("PivotTable1").SmallGrid = False ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="mach_name", _ ColumnFields:="tool" Sheets("report").Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Limit long text to right footer section | Excel Discussion (Misc queries) | |||
Get section of text from cell | Excel Worksheet Functions | |||
Wrap text in header section Excel 2007 | Excel Discussion (Misc queries) | |||
Converting selected section of text to numbers | Excel Discussion (Misc queries) | |||
Stripping section of text | Excel Worksheet Functions |