Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 64
Default input box

Hello folks,

I have the folowing vb script which I have managed to cobble together and it
works very well. Except that is if the user cancels instead of entering a
date at which point it errors. I would really like it if the user cancels
then that would cancel the macro.


Help.

Thanks,

Mike

Dim queryDate As Date
Application.ScreenUpdating = False
Sheets("NSKData").Select
Range("A1").Select
Range("A1:E1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Selection.QueryTable.Delete
'Range("G1").Select
'queryDate = Range("G1")
queryDate = InputBox("Enter a Date")
With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=trop;UID=MAYNEM
;PWD=trader;DBQ=TROP.WORLD;DBA=W;APA=T;EXC=F;FEN=T ;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=F;BAM=I fAllSuccessful;MTS=" _
), Array("F;MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;")),
Destination:=Range("A1"))
.CommandText = Array( _
"select trading_date, period, sum(band1_6sec_max)
,sum(band1_60sec_max)from tr_owner.tr_pcmp_offer_summ where status = 'c' and
asset_owner_code = 'SKOG'and trading_date = '" & queryDate & "' group by
trading_date, period order " _
, "by 1, 2")
.Name = "Query from trop"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
Sheets("ChartNSK").Select
Application.ScreenUpdating = True
End Sub



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Prevent Duplicate Data from inputing using input application? Zigball Excel Worksheet Functions 8 October 16th 06 11:01 PM
How to Prevent Duplicate Data from inputing using input application? Zigball Excel Discussion (Misc queries) 1 October 10th 06 05:56 PM
How to Prevent Duplicate Data from inputing using input application? Zigball New Users to Excel 1 October 10th 06 05:31 PM
input box Monty Excel Discussion (Misc queries) 2 October 7th 05 08:33 AM
Input Form vba help mdalzell Excel Discussion (Misc queries) 0 April 8th 05 03:57 PM


All times are GMT +1. The time now is 09:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"