• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How can I use ENTER key instead of clicking on the button

lutek98

New Member
Can you help me with a code? How can I use ENTER key instead of clicking Button10?
Here is the code for the button:

Sub Button10_Click()
'
Range("B1:D1") = Null
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.airport-data.com/aircraft/" & "N" & Range("A1").Value & ".html", Destination:=Range( _
"$C$1"))
.Name = "D1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "1"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False



End With

Range("D1") = Right(Range("D1"), Len(Range("D1")) - 5)


Dim i As String
Dim k As String
i = " C/N"
k = " C/N"
Columns("D").Replace what:=i, replacement:=k, lookat:=xlPart, MatchCase:=False

Range("D1") = Range("D1") & ", " & Range("C1")

Range(Cells(2, 3), Cells(2, 4)).Value = Null

Range("B1:C1") = Null

Columns("D:D").ColumnWidth = 68

Sheet1.Range("D1").Copy

Range("A1").Select

End Sub
 
Hi ,

Can you explain why you want this change ?

The ENTER key by itself cannot be recognized , unless you use the Windows API , which seems overkill for such a simple procedure.

Pressing the ENTER key will however change the cursor location , and this can be recognized through the Worksheet_SelectionChange procedure ; however , for this to work , you need to designate any one cell where the cursor will be located for the procedure to get triggered. Or do you want that where ever the cursor is , the procedure should be executed ?

Narayan
 
Back
Top