Edit the date and time inside code using a text box

S.Daniels

New Member
Joined
Nov 1, 2005
Messages
37
I have a macro I run that quries a data base then returns the information. I need to be able to edit the start and end date using text boxes if i can. Could someone show me how. This is the code.

Sheets("ShiftDown_Data").Select
Range("D5").Select
ActiveSheet.PivotTableWizard SourceType:=xlExternal, SourceData:=Array( _
"SELECT ss_hist_base.mach_name, ss_hist_dar.down_reason, Sum(ss_hist_dar.down_time), ss_hist_base.shift_id" & Chr(13) & "" & Chr(10) & "FROM plantstar.ss_hist_base ss_hist_base, plantstar.ss_hist_dar ss_hist_dar" & Chr(13) & "" & Chr(10) & "WHERE ss_hist_ba" _
, _
"se.child_idx = ss_hist_dar.child_idx AND ss_hist_base.mach_seq = ss_hist_dar.mach_seq AND ss_hist_dar.ss_mseq = ss_hist_base.ss_mseq AND ((ss_hist_base.start_time>'03-sep-2005 07:00:00' And ss_hist_ba" _
, _
"se.start_time<'15-sep-2005 07:00:00'))" & Chr(13) & "" & Chr(10) & "GROUP BY ss_hist_base.mach_name, ss_hist_dar.down_reason, ss_hist_base.shift_id" _
), Connection:= _
"ODBC;DSN=OPENINGRES;SERVER=PLANTSTAR;DATABASE=focus2000;SERVERTYPE=INGRES"
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=Array("mach_name" _
, "shift_id"), ColumnFields:="down_reason"
End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,203,686
Messages
6,056,737
Members
444,888
Latest member
Babi_mn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top